Skip to content

Commit

Permalink
feat: check total item badge setting on entries update
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoung19 committed Sep 20, 2024
1 parent c4512fa commit 4a42523
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { createHash } from "crypto";

import { Storage } from "@plasmohq/storage";

import { getSettings } from "~storage/settings";
import { Entry } from "~types/entry";

import { setActionBadgeText } from "./actionBadge";
import { removeActionBadgeText, setActionBadgeText } from "./actionBadge";

// Do not change this without a migration.
const ENTRIES_STORAGE_KEY = "entryIdSetentries";
Expand Down Expand Up @@ -35,9 +36,11 @@ export const getEntries = async () => {
};

export const setEntries = async (entries: Entry[]) => {
const settings = await getSettings();

await Promise.all([
storage.set(ENTRIES_STORAGE_KEY, entries),
setActionBadgeText(entries.length),
settings.totalItemsBadge ? setActionBadgeText(entries.length) : removeActionBadgeText(),
]);
};

Expand Down

0 comments on commit 4a42523

Please sign in to comment.