Skip to content

Commit ef91d8b

Browse files
authored
Merge pull request #138 from vedansh-5/bug
Fixes the subject injection in email and yahoo
2 parents e3cee1a + 4c6e252 commit ef91d8b

File tree

1 file changed

+39
-23
lines changed

1 file changed

+39
-23
lines changed

src/scripts/scrumHelper.js

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ function allIncluded(outputTarget = 'email') {
2020
let githubPrsReviewData = null;
2121
let githubUserData = null;
2222
let githubPrsReviewDataProcessed = {};
23+
let issuesDataProcessed = false;
24+
let prsReviewDataProcessed = false;
2325
let showOpenLabel = true;
2426
let showClosedLabel = true;
2527
let userReason = '';
@@ -526,7 +528,7 @@ ${userReason}`;
526528
if (date < 10) date = '0' + date;
527529
let dateCode = year.toString() + month.toString() + date.toString();
528530

529-
const subject = `[Scrum] ${name} - ${project} - ${dateCode} - False`;
531+
const subject = `[Scrum] ${name} - ${project} - ${dateCode}`;
530532
log('Generated subject:', subject);
531533
githubCache.subject = subject;
532534
saveToStorage(githubCache.data, subject);
@@ -622,9 +624,23 @@ ${userReason}`;
622624
reviewedPrsArray.push(repoLi);
623625
}
624626

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() {
628644
let items = githubIssuesData.items;
629645
lastWeekArray = [];
630646
nextWeekArray = [];
@@ -650,7 +666,6 @@ ${userReason}`;
650666
} else {
651667
// is a issue
652668
if (item.state === 'open' && item.body?.toUpperCase().indexOf('YES') > 0) {
653-
//probably the author wants to work on this issue!
654669
let li2 =
655670
'<li><i>(' +
656671
project +
@@ -684,18 +699,19 @@ ${userReason}`;
684699
}
685700
lastWeekArray.push(li);
686701
}
687-
writeScrumBody();
688-
}
702+
issuesDataProcessed = true;
703+
triggerScrumGeneration();
704+
}
689705

690-
let intervalBody = setInterval(() => {
706+
let intervalBody = setInterval(() => {
691707
if (!window.emailClientAdapter) return;
692708

693709
const elements = window.emailClientAdapter.getEditorElements();
694710
if (!elements || !elements.body) return;
695711

696712
clearInterval(intervalBody);
697713
scrumBody = elements.body;
698-
writeScrumBody();
714+
// writeScrumBody(); // This call is premature and causes the issue.
699715
}, 500);
700716

701717
let intervalSubject = setInterval(() => {
@@ -732,20 +748,20 @@ ${userReason}`;
732748
}
733749
}
734750
}, 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) {
749765
let intervalWriteButton = setInterval(() => {
750766
if (document.getElementsByClassName('F0XO1GC-x-b').length == 3 && scrumBody && enableToggle) {
751767
refreshButton_Placed = true;

0 commit comments

Comments
 (0)