mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-03 21:02:40 +02:00
feat(ui): surface pinned premium quota alerts in chat thread
This commit is contained in:
parent
835bd9f65d
commit
d5ef0d2598
3 changed files with 148 additions and 10 deletions
33
surfsense_web/atoms/chat/premium-alert.atom.ts
Normal file
33
surfsense_web/atoms/chat/premium-alert.atom.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { atom } from "jotai";
|
||||
|
||||
export type PremiumAlertState = {
|
||||
message: string;
|
||||
};
|
||||
|
||||
export const premiumAlertByThreadAtom = atom<Record<number, PremiumAlertState>>({});
|
||||
|
||||
export const setPremiumAlertForThreadAtom = atom(
|
||||
null,
|
||||
(
|
||||
get,
|
||||
set,
|
||||
payload: {
|
||||
threadId: number;
|
||||
message: string;
|
||||
}
|
||||
) => {
|
||||
const current = get(premiumAlertByThreadAtom);
|
||||
set(premiumAlertByThreadAtom, {
|
||||
...current,
|
||||
[payload.threadId]: { message: payload.message },
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
export const clearPremiumAlertForThreadAtom = atom(null, (get, set, threadId: number) => {
|
||||
const current = get(premiumAlertByThreadAtom);
|
||||
if (!(threadId in current)) return;
|
||||
const next = { ...current };
|
||||
delete next[threadId];
|
||||
set(premiumAlertByThreadAtom, next);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue