From 4a4252350ce4fcfc6b037fe6dc535491c7baa700 Mon Sep 17 00:00:00 2001 From: ayoung19 Date: Fri, 20 Sep 2024 07:39:19 -0700 Subject: [PATCH] feat: check total item badge setting on entries update --- utils/storage.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/storage.ts b/utils/storage.ts index a8dc0b5..3cb7342 100644 --- a/utils/storage.ts +++ b/utils/storage.ts @@ -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"; @@ -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(), ]); };