@@ -20,6 +20,8 @@ function allIncluded(outputTarget = 'email') {
20
20
let githubPrsReviewData = null ;
21
21
let githubUserData = null ;
22
22
let githubPrsReviewDataProcessed = { } ;
23
+ let issuesDataProcessed = false ;
24
+ let prsReviewDataProcessed = false ;
23
25
let showOpenLabel = true ;
24
26
let showClosedLabel = true ;
25
27
let userReason = '' ;
@@ -622,9 +624,23 @@ ${userReason}`;
622
624
reviewedPrsArray . push ( repoLi ) ;
623
625
}
624
626
625
- writeScrumBody ( ) ;
626
- }
627
- function writeGithubIssuesPrs ( ) {
627
+ prsReviewDataProcessed = true ;
628
+ triggerScrumGeneration ( ) ;
629
+ }
630
+
631
+ function triggerScrumGeneration ( ) {
632
+ if ( issuesDataProcessed && prsReviewDataProcessed ) {
633
+ log ( 'Both data sets processed, generating scrum body.' ) ;
634
+ writeScrumBody ( ) ;
635
+ } else {
636
+ log ( 'Waiting for all data to be processed before generating scrum.' , {
637
+ issues : issuesDataProcessed ,
638
+ reviews : prsReviewDataProcessed ,
639
+ } ) ;
640
+ }
641
+ }
642
+
643
+ function writeGithubIssuesPrs ( ) {
628
644
let items = githubIssuesData . items ;
629
645
lastWeekArray = [ ] ;
630
646
nextWeekArray = [ ] ;
@@ -650,7 +666,6 @@ ${userReason}`;
650
666
} else {
651
667
// is a issue
652
668
if ( item . state === 'open' && item . body ?. toUpperCase ( ) . indexOf ( 'YES' ) > 0 ) {
653
- //probably the author wants to work on this issue!
654
669
let li2 =
655
670
'<li><i>(' +
656
671
project +
@@ -684,18 +699,19 @@ ${userReason}`;
684
699
}
685
700
lastWeekArray . push ( li ) ;
686
701
}
687
- writeScrumBody ( ) ;
688
- }
702
+ issuesDataProcessed = true ;
703
+ triggerScrumGeneration ( ) ;
704
+ }
689
705
690
- let intervalBody = setInterval ( ( ) => {
706
+ let intervalBody = setInterval ( ( ) => {
691
707
if ( ! window . emailClientAdapter ) return ;
692
708
693
709
const elements = window . emailClientAdapter . getEditorElements ( ) ;
694
710
if ( ! elements || ! elements . body ) return ;
695
711
696
712
clearInterval ( intervalBody ) ;
697
713
scrumBody = elements . body ;
698
- writeScrumBody ( ) ;
714
+ // writeScrumBody(); // This call is premature and causes the issue.
699
715
} , 500 ) ;
700
716
701
717
let intervalSubject = setInterval ( ( ) => {
@@ -732,20 +748,20 @@ ${userReason}`;
732
748
}
733
749
}
734
750
} , 500 ) ;
735
- let intervalWriteGithubPrs = setInterval ( ( ) => {
736
- if ( outputTarget === 'popup' ) {
737
- if ( githubUsername && githubPrsReviewData ) {
738
- clearInterval ( intervalWriteGithubPrs ) ;
739
- writeGithubPrsReviews ( ) ;
740
- }
741
- } else {
742
- if ( scrumBody && githubUsername && githubPrsReviewData ) {
743
- clearInterval ( intervalWriteGithubPrs ) ;
744
- writeGithubPrsReviews ( ) ;
745
- }
746
- }
747
- } , 500 ) ;
748
- if ( ! refreshButton_Placed ) {
751
+ let intervalWriteGithubPrs = setInterval ( ( ) => {
752
+ if ( outputTarget === 'popup' ) {
753
+ if ( githubUsername && githubPrsReviewData ) {
754
+ clearInterval ( intervalWriteGithubPrs ) ;
755
+ writeGithubPrsReviews ( ) ;
756
+ }
757
+ } else {
758
+ if ( scrumBody && githubUsername && githubPrsReviewData ) {
759
+ clearInterval ( intervalWriteGithubPrs ) ;
760
+ writeGithubPrsReviews ( ) ;
761
+ }
762
+ }
763
+ } , 500 ) ;
764
+ if ( ! refreshButton_Placed ) {
749
765
let intervalWriteButton = setInterval ( ( ) => {
750
766
if ( document . getElementsByClassName ( 'F0XO1GC-x-b' ) . length == 3 && scrumBody && enableToggle ) {
751
767
refreshButton_Placed = true ;
0 commit comments