feat(call_to_action): allow dismissal

This commit is contained in:
Elian Doran
2025-08-12 19:37:32 +03:00
parent b2db87db4e
commit bac048f60f
5 changed files with 32 additions and 6 deletions

View File

@@ -52,5 +52,26 @@ const CALL_TO_ACTIONS: CallToAction[] = [
];
export function getCallToActions() {
return CALL_TO_ACTIONS.filter((callToAction) => callToAction.enabled());
const seenCallToActions = new Set(getSeenCallToActions());
return CALL_TO_ACTIONS.filter((callToAction) =>
!seenCallToActions.has(callToAction.id) && callToAction.enabled());
}
export async function dismissCallToAction(id: string) {
const seenCallToActions = getSeenCallToActions();
if (seenCallToActions.find(seenId => seenId === id)) {
return;
}
seenCallToActions.push(id);
await options.save("seenCallToActions", JSON.stringify(seenCallToActions));
}
function getSeenCallToActions() {
try {
return JSON.parse(options.get("seenCallToActions")) as string[];
} catch (e) {
return [];
}
}