mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-03 21:02:40 +02:00
feat(chat): add userId to premium alert handling and improve alert visibility in UI
This commit is contained in:
parent
901de33684
commit
e6db050dfd
4 changed files with 21 additions and 6 deletions
|
|
@ -1032,6 +1032,7 @@ export default function NewChatPage() {
|
|||
setPremiumAlertForThread({
|
||||
threadId: currentThreadId,
|
||||
message: premiumQuotaAlertMessage,
|
||||
userId: currentUser?.id ?? null,
|
||||
});
|
||||
} else {
|
||||
toast.error("Failed to get response. Please try again.");
|
||||
|
|
@ -1334,6 +1335,7 @@ export default function NewChatPage() {
|
|||
setPremiumAlertForThread({
|
||||
threadId: resumeThreadId,
|
||||
message: premiumQuotaAlertMessage,
|
||||
userId: currentUser?.id ?? null,
|
||||
});
|
||||
} else {
|
||||
toast.error("Failed to resume. Please try again.");
|
||||
|
|
@ -1692,6 +1694,7 @@ export default function NewChatPage() {
|
|||
setPremiumAlertForThread({
|
||||
threadId,
|
||||
message: premiumQuotaAlertMessage,
|
||||
userId: currentUser?.id ?? null,
|
||||
});
|
||||
} else {
|
||||
toast.error("Failed to regenerate response. Please try again.");
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -161,15 +161,15 @@ const PremiumQuotaPinnedAlert: FC = () => {
|
|||
if (!alert) return null;
|
||||
|
||||
return (
|
||||
<div className="mx-0 bg-amber-500/10 px-3 py-2 text-amber-100">
|
||||
<div className="flex items-start gap-2">
|
||||
<AlertCircle className="mt-0.5 size-4 shrink-0 text-amber-300" />
|
||||
<div className="mx-0 overflow-hidden rounded-2xl border-input bg-muted px-4 py-4 text-foreground select-none">
|
||||
<div className="flex items-center gap-2">
|
||||
<AlertCircle className="size-4 shrink-0 text-muted-foreground" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm">{alert.message}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex size-6 items-center justify-center text-amber-200 transition-colors hover:text-amber-50"
|
||||
className="inline-flex size-6 items-center justify-center text-muted-foreground transition-colors hover:text-foreground"
|
||||
aria-label="Dismiss premium quota alert"
|
||||
onClick={() => clearPremiumAlertForThread(currentThreadId)}
|
||||
>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue