feat(chat): add userId to premium alert handling and improve alert visibility in UI

This commit is contained in:
Anish Sarkar 2026-04-29 21:58:17 +05:30
parent 901de33684
commit e6db050dfd
4 changed files with 21 additions and 6 deletions

View file

@ -14,13 +14,25 @@ export const setPremiumAlertForThreadAtom = atom(
payload: {
threadId: number;
message: string;
userId?: string | null;
}
) => {
const storageKey = `surfsense-premium-alert-seen-v1:${payload.userId ?? "anonymous"}`;
if (typeof window !== "undefined") {
const hasSeen = localStorage.getItem(storageKey) === "true";
if (hasSeen) return;
}
const current = get(premiumAlertByThreadAtom);
set(premiumAlertByThreadAtom, {
...current,
[payload.threadId]: { message: payload.message },
});
if (typeof window !== "undefined") {
localStorage.setItem(storageKey, "true");
}
}
);