Skip to content

Commit feb87cb

Browse files
committed
rebase fix2
Signed-off-by: Vedansh Saini <[email protected]>
1 parent 9b29c34 commit feb87cb

File tree

1 file changed

+67
-66
lines changed

1 file changed

+67
-66
lines changed

src/scripts/scrumHelper.js

Lines changed: 67 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
console.log("Script loaded", new Date().toISOString());
21
console.log('Script loaded, adapter exists:', !!window.emailClientAdapter);
32
let refreshButton_Placed = false;
43
let enableToggle = true;
@@ -410,13 +409,6 @@ function allIncluded(outputTarget = 'email') {
410409
reviewedPrsArray = [];
411410
githubPrsReviewDataProccessed = {};
412411

413-
log('Writing issues from process')
414-
writeGithubIssuesPrs();
415-
log('Writing prs from process')
416-
writeGithubPrsReviews();
417-
log('Writing body from process')
418-
writeScrumBody();
419-
420412
// Update subject
421413
if(!githubCache.subject && scrumSubject) {
422414
scrumSubjectLoaded();
@@ -431,7 +423,7 @@ function allIncluded(outputTarget = 'email') {
431423

432424
//load initial text in scrum body
433425
function writeScrumBody() {
434-
if (!enableToggle || (outputTarget === 'email' && hasInjectedContent)) return;
426+
if (!enableToggle || hasInjectedContent) return;
435427

436428
if(outputTarget ==='email') {
437429
if(!window.emailClientAdapter) {
@@ -461,22 +453,22 @@ function allIncluded(outputTarget = 'email') {
461453

462454
// Create the complete content
463455
let content;
464-
if (lastWeekContribution == true) {
465-
content = `<b>1. What did I do ${weekOrDay}?</b><br>
466-
${lastWeekUl}<br>
467-
<b>2. What do I plan to do ${weekOrDay2}?</b><br>
468-
${nextWeekUl}<br>
469-
<b>3. What is stopping me from doing my work?</b><br>
470-
${userReason}`;
471-
} else {
472-
content = `<b>1. What did I do from ${formatDate(startingDate)} to ${formatDate(endingDate)}?</b><br>
473-
${lastWeekUl}<br>
474-
<b>2. What do I plan to do ${weekOrDay2}?</b><br>
475-
${nextWeekUl}<br>
476-
<b>3. What is stopping me from doing my work?</b><br>
477-
${userReason}`;
478-
}
479-
456+
if (lastWeekContribution == true) {
457+
content = `<b>1. What did I do ${weekOrDay}?</b>
458+
<br>${lastWeekUl}<br><br>
459+
<b>2. What I plan to do ${weekOrDay2}?</b>
460+
<br>${nextWeekUl}<br><br>
461+
<b>3. What is stopping me from doing my work?</b>
462+
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${userReason}</p>`;
463+
} else {
464+
content = `<b>1. What did I do from ${formatDate(startingDate)} to ${formatDate(endingDate)}?</b>
465+
<br>${lastWeekUl}<br><br>
466+
<b>2. What I plan to do ${weekOrDay2}?</b>
467+
<br>${nextWeekUl}<br><br>
468+
<b>3. What is stopping me from doing my work?</b>
469+
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${userReason}</p>`;
470+
}
471+
480472

481473
if (outputTarget === 'popup') {
482474
const scrumReport = document.getElementById('scrumReport');
@@ -501,43 +493,43 @@ function allIncluded(outputTarget = 'email') {
501493
return;
502494
}
503495
window.emailClientAdapter.injectContent(elements.body, content, elements.eventTypes.contentChange);
496+
hasInjectedContent = true;
504497
}
505-
hasInjectedContent = true;
506498
}, 500);
507499
}
508500

509501
//load initial scrum subject
510502
function scrumSubjectLoaded() {
511503
try{
512-
if (!enableToggle || hasInjectedContent) return;
513-
if (!scrumSubject){
514-
console.error('Subject element not found');
515-
return;
516-
}
517-
setTimeout(() => {
518-
let name = githubUserData.name || githubUsername;
519-
let project = projectName || '<project name>';
520-
let curDate = new Date();
521-
let year = curDate.getFullYear().toString();
522-
let date = curDate.getDate();
523-
let month = curDate.getMonth();
524-
month++;
525-
if (month < 10) month = '0' + month;
526-
if (date < 10) date = '0' + date;
527-
let dateCode = year.toString() + month.toString() + date.toString();
528-
529-
const subject = `[Scrum] ${name} - ${project} - ${dateCode} - False`;
504+
if (!enableToggle || hasInjectedContent) return;
505+
if (!scrumSubject){
506+
console.error('Subject element not found');
507+
return;
508+
}
509+
setTimeout(() => {
510+
let name = githubUserData.name || githubUsername;
511+
let project = projectName || '<project name>';
512+
let curDate = new Date();
513+
let year = curDate.getFullYear().toString();
514+
let date = curDate.getDate();
515+
let month = curDate.getMonth();
516+
month++;
517+
if (month < 10) month = '0' + month;
518+
if (date < 10) date = '0' + date;
519+
let dateCode = year.toString() + month.toString() + date.toString();
520+
521+
const subject = `[Scrum] ${name} - ${project} - ${dateCode} - False`;
530522
log('Generated subject:', subject);
531-
githubCache.subject = subject;
532-
saveToStorage(githubCache.data, subject);
523+
githubCache.subject = subject;
524+
saveToStorage(githubCache.data, subject);
533525

534-
if(scrumSubject && scrumSubject.value !== subject) {
535-
scrumSubject.value = subject;
536-
scrumSubject.dispatchEvent(new Event('input', { bubbles: true }));
537-
}
538-
});
526+
if(scrumSubject && scrumSubject.value !== subject) {
527+
scrumSubject.value = subject;
528+
scrumSubject.dispatchEvent(new Event('input', { bubbles: true }));
529+
}
530+
});
539531
} catch(err){
540-
console.err('Error while setting subject: ', err);
532+
console.err('Error while setting subject: ', err);
541533
}
542534
}
543535

@@ -552,8 +544,8 @@ function allIncluded(outputTarget = 'email') {
552544
logError('No Github PR review data available');
553545
return;
554546
}
555-
reviewedPrsArray = [];
556-
githubPrsReviewDataProcessed = {};
547+
// reviewedPrsArray = [];
548+
// githubPrsReviewDataProcessed = {};
557549
let i;
558550
for (i = 0; i < items.length; i++) {
559551
let item = items[i];
@@ -626,8 +618,8 @@ function allIncluded(outputTarget = 'email') {
626618
}
627619
function writeGithubIssuesPrs() {
628620
let items = githubIssuesData.items;
629-
lastWeekArray = [];
630-
nextWeekArray = [];
621+
// lastWeekArray = [];
622+
// nextWeekArray = [];
631623
if(!items){
632624
logError('No Github issues data available');
633625
}
@@ -668,12 +660,20 @@ function allIncluded(outputTarget = 'email') {
668660
li = `<li><i>(${project})</i> - Opened Issue(#${number}) - <a href='${html_url}'>${title}</a> ${issue_opened_button}</li>`;
669661
} else if (item.state === 'closed') {
670662
li = `<li><i>(${project})</i> - Opened Issue(#${number}) - <a href='${html_url}'>${title}</a> ${issue_closed_button}</li>`;
663+
} else {
664+
li =
665+
'<li><i>(' +
666+
project +
667+
')</i> - Opened Issue(#' +
668+
number +
669+
") - <a href='" +
670+
html_url +
671+
"' target='_blank'>" +
672+
title +
673+
'</a> </li>';
671674
}
672675
}
673-
if (li) {
674676
lastWeekArray.push(li);
675-
} else {
676-
}
677677
}
678678
writeScrumBody();
679679
}
@@ -703,9 +703,10 @@ function allIncluded(outputTarget = 'email') {
703703

704704
clearInterval(intervalSubject);
705705
scrumSubject = elements.subject;
706-
if(!scrumSubject.value) {
706+
707+
setTimeout(() => {
707708
scrumSubjectLoaded();
708-
}
709+
}, 500);
709710
}, 500);
710711

711712
//check for github safe writing
@@ -752,6 +753,10 @@ $('button>span:contains(New conversation)').parent('button').click(() => {
752753
allIncluded();
753754
});
754755

756+
window.generateScrumReport = function() {
757+
allIncluded('popup');
758+
}
759+
755760
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
756761
if(request.action === 'forceRefresh') {
757762
forceGithubDataRefresh()
@@ -761,8 +766,4 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
761766
});
762767
return true;
763768
}
764-
});
765-
766-
window.generateScrumReport = function() {
767-
allIncluded('popup');
768-
}
769+
});

0 commit comments

Comments
 (0)