mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-21 22:31:46 +00:00
fix(system-notices): reset notice store on logout so addon-gated notices show after re-login
This commit is contained in:
@@ -151,6 +151,7 @@ export const useAuthStore = create<AuthState>()(
|
|||||||
|
|
||||||
logout: () => {
|
logout: () => {
|
||||||
disconnect()
|
disconnect()
|
||||||
|
useSystemNoticeStore.getState().reset()
|
||||||
// Tell server to clear the httpOnly cookie
|
// Tell server to clear the httpOnly cookie
|
||||||
fetch('/api/auth/logout', { method: 'POST', credentials: 'include' }).catch(() => {})
|
fetch('/api/auth/logout', { method: 'POST', credentials: 'include' }).catch(() => {})
|
||||||
// Clear service worker caches containing sensitive data
|
// Clear service worker caches containing sensitive data
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ interface SystemNoticeState {
|
|||||||
fetching: boolean;
|
fetching: boolean;
|
||||||
fetch: () => Promise<void>;
|
fetch: () => Promise<void>;
|
||||||
dismiss: (id: string) => void;
|
dismiss: (id: string) => void;
|
||||||
|
reset: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSystemNoticeStore = create<SystemNoticeState>()((set, get) => ({
|
export const useSystemNoticeStore = create<SystemNoticeState>()((set, get) => ({
|
||||||
@@ -51,6 +52,10 @@ export const useSystemNoticeStore = create<SystemNoticeState>()((set, get) => ({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
set({ notices: [], loaded: false, fetching: false });
|
||||||
|
},
|
||||||
|
|
||||||
dismiss(id: string) {
|
dismiss(id: string) {
|
||||||
// Optimistic: remove immediately
|
// Optimistic: remove immediately
|
||||||
const prev = get().notices;
|
const prev = get().notices;
|
||||||
|
|||||||
Reference in New Issue
Block a user