@@ -2,8 +2,14 @@ console.log('Script loaded, adapter exists:', !!window.emailClientAdapter);
2
2
let refreshButton_Placed = false ;
3
3
let enableToggle = true ;
4
4
let hasInjectedContent = false ;
5
+ let scrumGenerationInProgress = false ;
5
6
let orgName = 'fossasia' ; // default
6
7
function allIncluded ( outputTarget = 'email' ) {
8
+ if ( scrumGenerationInProgress ) {
9
+ console . warn ( '[SCRUM-HELPER]: Scrum generation already in progress, aborting new call.' ) ;
10
+ return ;
11
+ }
12
+ scrumGenerationInProgress = true ;
7
13
console . log ( 'allIncluded called with outputTarget:' , outputTarget ) ;
8
14
console . log ( 'Current window context:' , window . location . href ) ;
9
15
let scrumBody = null ;
@@ -99,9 +105,14 @@ function allIncluded(outputTarget = 'email') {
99
105
handleLastWeekContributionChange ( ) ;
100
106
} else if ( items . yesterdayContribution ) {
101
107
handleYesterdayContributionChange ( ) ;
102
- } else {
108
+ } else if ( items . startDate && items . endingDate ) {
103
109
startingDate = items . startingDate ;
104
110
endingDate = items . endingDate ;
111
+ } else {
112
+ handleLastWeekContributionChange ( ) ; //when no date is stored, i.e on fresh unpack - default to last week.
113
+ if ( outputTarget === 'popup' ) {
114
+ chrome . storage . local . set ( { lastWeekContribution : true , yesterdayContribution : false } ) ;
115
+ }
105
116
}
106
117
107
118
if ( githubUsername ) {
@@ -417,6 +428,7 @@ function allIncluded(outputTarget = 'email') {
417
428
generateBtn . disabled = false ;
418
429
}
419
430
}
431
+ scrumGenerationInProgress = false ;
420
432
throw err ;
421
433
} finally {
422
434
githubCache . fetching = false ;
@@ -550,8 +562,10 @@ ${userReason}`;
550
562
generateBtn . innerHTML = '<i class="fa fa-refresh"></i> Generate Report' ;
551
563
generateBtn . disabled = false ;
552
564
}
565
+ scrumGenerationInProgress = false ;
553
566
} else {
554
567
logError ( 'Scrum report div not found' ) ;
568
+ scrumGenerationInProgress = false ;
555
569
}
556
570
} else {
557
571
const elements = window . emailClientAdapter . getEditorElements ( ) ;
@@ -561,6 +575,7 @@ ${userReason}`;
561
575
}
562
576
window . emailClientAdapter . injectContent ( elements . body , content , elements . eventTypes . contentChange ) ;
563
577
hasInjectedContent = true ;
578
+ scrumGenerationInProgress = false ;
564
579
}
565
580
} , 500 ) ;
566
581
}
@@ -843,11 +858,14 @@ ${userReason}`;
843
858
}
844
859
}
845
860
846
- allIncluded ( 'email' ) ;
861
+ // allIncluded('email');
847
862
848
- $ ( 'button>span:contains(New conversation)' ) . parent ( 'button' ) . click ( ( ) => {
849
- allIncluded ( ) ;
850
- } ) ;
863
+ if ( window . location . protocol . startsWith ( 'http' ) ) {
864
+ allIncluded ( 'email' ) ;
865
+ $ ( 'button>span:contains(New conversation)' ) . parent ( 'button' ) . click ( ( ) => {
866
+ allIncluded ( ) ;
867
+ } ) ;
868
+ }
851
869
852
870
window . generateScrumReport = function ( ) {
853
871
allIncluded ( 'popup' ) ;
0 commit comments