Skip to content

Commit d41d407

Browse files
shweta2101cyrossignol
authored andcommitted
Clear timeout; fix storage and header parsing
Clear the pending timeout on ProjectGroupPicker unmount to avoid leaked timers. Switch saved project/group keys removal from localStorage to sessionStorage and also remove the project-group-name key to fully clear auth selection. Harden parsing of the X-Total-Count response header: treat invalid/NaN parses as null to avoid returning an incorrect numeric value.
1 parent f97df64 commit d41d407

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

components/ProjectGroupPicker.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ onMounted(async () => {
285285
286286
onUnmounted(() => {
287287
document.removeEventListener('mousedown', handleClickOutside)
288+
clearTimeout(timeoutId)
288289
})
289290
</script>
290291

services/tdei.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ export class TdeiAuthStore {
123123
this.refreshExpiresAt = new Date(0);
124124

125125
localStorage.removeItem(this._storageKey);
126-
localStorage.removeItem('tdei-selected-project-group');
127-
localStorage.removeItem('tdei-selected-workspace');
126+
sessionStorage.removeItem('tdei-selected-project-group');
127+
sessionStorage.removeItem('tdei-selected-project-group-name');
128+
sessionStorage.removeItem('tdei-selected-workspace');
128129
}
129130
}
130131

@@ -469,7 +470,8 @@ export class TdeiUserClient extends BaseHttpClient implements ICancelableClient
469470

470471
try {
471472
const totalHeader = response.headers.get('X-Total-Count');
472-
const total = totalHeader !== null ? parseInt(totalHeader, 10) : null;
473+
const totalParsed = totalHeader !== null ? parseInt(totalHeader, 10) : NaN;
474+
const total = Number.isNaN(totalParsed) ? null : totalParsed;
473475
const items = (await response.json() as TdeiProjectGroupApiResponse[]) ?? [];
474476
return { items: items.map(p => ({ id: p.tdei_project_group_id, name: p.project_group_name })), total };
475477
} catch (e) {

0 commit comments

Comments
 (0)