@@ -200,8 +200,32 @@ function allIncluded(outputTarget = 'email') {
200
200
}
201
201
}
202
202
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
+
203
227
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 ) ;
205
229
fetchGithubData ( ) ;
206
230
} else {
207
231
if ( outputTarget === 'popup' ) {
@@ -245,9 +269,6 @@ function allIncluded(outputTarget = 'email') {
245
269
githubCache . timestamp = items . githubCache . timestamp ;
246
270
log ( 'Restored cache from storage' ) ;
247
271
}
248
- if ( items . orgName ) {
249
- orgName = items . orgName ;
250
- }
251
272
} ,
252
273
) ;
253
274
}
@@ -488,10 +509,6 @@ function allIncluded(outputTarget = 'email') {
488
509
await saveToStorage ( githubCache . data ) ;
489
510
processGithubData ( githubCache . data ) ;
490
511
491
- if ( outputTarget === 'popup' ) {
492
- resetReportState ( true , 'popup' ) ;
493
- }
494
-
495
512
// Resolve queued calls
496
513
githubCache . queue . forEach ( ( { resolve } ) => resolve ( ) ) ;
497
514
githubCache . queue = [ ] ;
@@ -576,9 +593,6 @@ function allIncluded(outputTarget = 'email') {
576
593
user : githubUserData ?. login
577
594
} ) ;
578
595
579
- // Reset data arrays and processing state
580
- resetReportState ( false ) ;
581
-
582
596
// Update subject
583
597
if ( ! githubCache . subject && scrumSubject ) {
584
598
scrumSubjectLoaded ( ) ;
@@ -1050,6 +1064,7 @@ ${userReason}`;
1050
1064
} , 1000 ) ;
1051
1065
}
1052
1066
function handleRefresh ( ) {
1067
+ hasInjectedContent = false ;
1053
1068
resetReportState ( false , 'email' ) ;
1054
1069
allIncluded ( ) ;
1055
1070
}
0 commit comments