Skip to content

Commit

Permalink
Push announcements as viewed on fresh install
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfou committed Nov 10, 2024
1 parent 93dd44b commit 99176fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/background/announcements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ const getAnnouncements = async (): Promise<Record<string, boolean>> => {
return announcements;
};

const addAnnouncement = async (announcement: string): Promise<void> => {
const addAnnouncement = async (
announcement: string,
isActive: boolean
): Promise<void> => {
const announcements = await getAnnouncements();
if (announcement in announcements) {
return;
}
await chrome.storage.local.set({
[KEY]: { ...announcements, [announcement]: true },
[KEY]: { ...announcements, [announcement]: isActive },
});
};

Expand Down
4 changes: 2 additions & 2 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const extensionInitialization = initialize(registeredUrls);

chrome.runtime.onInstalled.addListener(async ({ reason }) => {
await extensionInitialization;
if (reason !== "update") {
if (reason !== "install" && reason !== "update") {
return;
}
await addAnnouncement("custom-domains");
await addAnnouncement("custom-domains", reason === "update");
await refreshIcon();
});

Expand Down

0 comments on commit 99176fb

Please sign in to comment.