fix(notifications): access-requests nudge auto-clears on approval
The admin access-requests notice was issued from the on-user-load effect (keyed on user id), so it only re-resolved on a fresh load — it lingered until F5 after an approval dropped the pending count to 0. Move it to its own effect keyed on the pending count, so approving/denying (which refetches /api/me) clears or re-counts the notice live.
This commit is contained in:
parent
de58ded923
commit
ad77a1751e
1 changed files with 29 additions and 24 deletions
|
|
@ -365,12 +365,24 @@ export default function App() {
|
||||||
saveLayoutLocal(l);
|
saveLayoutLocal(l);
|
||||||
}
|
}
|
||||||
if (isSupported(prefs.language)) setLanguage(prefs.language);
|
if (isSupported(prefs.language)) setLanguage(prefs.language);
|
||||||
// Nudge admins when access requests are waiting (in lieu of a server-push bell).
|
// The demo account is shared: there are no subscriptions, so default it to the whole
|
||||||
const pending = meQuery.data?.pending_invites ?? 0;
|
// library (the "my" feed would be empty). The communal-state warning is a permanent
|
||||||
if (meQuery.data?.role === "admin") {
|
// banner (see DemoBanner below), not a toast that re-pops on every reload.
|
||||||
|
if (meQuery.data?.is_demo) {
|
||||||
|
setFilters({ ...loadStoredFilters(), scope: "all" });
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [meQuery.data?.id]);
|
||||||
|
|
||||||
|
// Nudge admins when access requests are waiting (in lieu of a server-push bell). Keyed on the
|
||||||
|
// pending COUNT so it re-resolves the moment an approval/denial changes it — not only on a
|
||||||
|
// fresh load (which is why the notice used to linger until F5 after an approval).
|
||||||
|
useEffect(() => {
|
||||||
|
if (meQuery.data?.role !== "admin") return;
|
||||||
// Keep a single, current nudge: drop any prior one (persisted copies reload as dismissed
|
// Keep a single, current nudge: drop any prior one (persisted copies reload as dismissed
|
||||||
// history, so they'd otherwise pile up one-per-reload) before re-issuing the live notice.
|
// history, so they'd otherwise pile up one-per-reload) before re-issuing the live notice.
|
||||||
removeByMetaKind("access-requests");
|
removeByMetaKind("access-requests");
|
||||||
|
const pending = meQuery.data.pending_invites ?? 0;
|
||||||
if (pending > 0) {
|
if (pending > 0) {
|
||||||
notify({
|
notify({
|
||||||
level: "warning",
|
level: "warning",
|
||||||
|
|
@ -388,15 +400,8 @@ export default function App() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// The demo account is shared: there are no subscriptions, so default it to the whole
|
|
||||||
// library (the "my" feed would be empty). The communal-state warning is a permanent
|
|
||||||
// banner (see DemoBanner below), not a toast that re-pops on every reload.
|
|
||||||
if (meQuery.data?.is_demo) {
|
|
||||||
setFilters({ ...loadStoredFilters(), scope: "all" });
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [meQuery.data?.id]);
|
}, [meQuery.data?.role, meQuery.data?.pending_invites]);
|
||||||
|
|
||||||
// Theme is part of the Settings draft: apply locally for preview, persist on Save.
|
// Theme is part of the Settings draft: apply locally for preview, persist on Save.
|
||||||
function setTheme(next: ThemePrefs) {
|
function setTheme(next: ThemePrefs) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue