Skip to content

Commit 8917488

Browse files
committed
fixed bug
1 parent e0b80f8 commit 8917488

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

src/scripts/popup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ document.addEventListener('DOMContentLoaded', function () {
399399

400400
// Valid org: update storage and fetch data
401401
await new Promise((resolve) => {
402-
chrome.storage.local.set({ orgName: org, githubCache: null }, resolve);
402+
chrome.storage.local.set({ orgName: org || 'fossasia', githubCache: null }, resolve);
403403
});
404404

405405
// Show success state

src/scripts/scrumHelper.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,32 @@ function allIncluded(outputTarget = 'email') {
200200
}
201201
}
202202

203+
// Always read orgName fresh from storage
204+
if (items.orgName) {
205+
orgName = items.orgName;
206+
} else {
207+
orgName = 'fossasia'; // fallback default
208+
}
209+
210+
// Defensive check for orgName
211+
if (!orgName || typeof orgName !== 'string' || orgName.trim() === '') {
212+
if (outputTarget === 'popup') {
213+
const scrumReport = document.getElementById('scrumReport');
214+
const generateBtn = document.getElementById('generateReport');
215+
if (scrumReport) {
216+
scrumReport.innerHTML = '<div class="error-message" style="color: #dc2626; font-weight: bold; padding: 10px;">Please set a valid organization before generating a report.</div>';
217+
}
218+
if (generateBtn) {
219+
generateBtn.innerHTML = '<i class="fa fa-refresh"></i> Generate Report';
220+
generateBtn.disabled = false;
221+
}
222+
scrumGenerationInProgress = false;
223+
}
224+
return;
225+
}
226+
203227
if (githubUsername) {
204-
console.log("About to fetch GitHub data for:", githubUsername);
228+
console.log("About to fetch GitHub data for:", githubUsername, "in org:", orgName);
205229
fetchGithubData();
206230
} else {
207231
if (outputTarget === 'popup') {
@@ -245,9 +269,6 @@ function allIncluded(outputTarget = 'email') {
245269
githubCache.timestamp = items.githubCache.timestamp;
246270
log('Restored cache from storage');
247271
}
248-
if (items.orgName) {
249-
orgName = items.orgName;
250-
}
251272
},
252273
);
253274
}
@@ -488,10 +509,6 @@ function allIncluded(outputTarget = 'email') {
488509
await saveToStorage(githubCache.data);
489510
processGithubData(githubCache.data);
490511

491-
if (outputTarget === 'popup') {
492-
resetReportState(true, 'popup');
493-
}
494-
495512
// Resolve queued calls
496513
githubCache.queue.forEach(({ resolve }) => resolve());
497514
githubCache.queue = [];
@@ -576,9 +593,6 @@ function allIncluded(outputTarget = 'email') {
576593
user: githubUserData?.login
577594
});
578595

579-
// Reset data arrays and processing state
580-
resetReportState(false);
581-
582596
// Update subject
583597
if (!githubCache.subject && scrumSubject) {
584598
scrumSubjectLoaded();
@@ -1050,6 +1064,7 @@ ${userReason}`;
10501064
}, 1000);
10511065
}
10521066
function handleRefresh() {
1067+
hasInjectedContent = false;
10531068
resetReportState(false, 'email');
10541069
allIncluded();
10551070
}

0 commit comments

Comments
 (0)