diff --git a/src/pages/content/injected.ts b/src/pages/content/injected.ts index f33e5fd9b..d5be6e636 100644 --- a/src/pages/content/injected.ts +++ b/src/pages/content/injected.ts @@ -2,7 +2,7 @@ import exampleThemeStorage from '@src/shared/storages/exampleThemeStorage'; async function toggleTheme() { console.log('initial theme', await exampleThemeStorage.get()); - exampleThemeStorage.toggle(); + await exampleThemeStorage.toggle(); console.log('toggled theme', await exampleThemeStorage.get()); } diff --git a/src/shared/storages/exampleThemeStorage.ts b/src/shared/storages/exampleThemeStorage.ts index fbf96f114..71aa3a6b6 100644 --- a/src/shared/storages/exampleThemeStorage.ts +++ b/src/shared/storages/exampleThemeStorage.ts @@ -14,8 +14,8 @@ const storage = createStorage('theme-storage-key', 'light', { const exampleThemeStorage: ThemeStorage = { ...storage, // TODO: extends your own methods - toggle: () => { - storage.set(currentTheme => { + toggle: async () => { + await storage.set(currentTheme => { return currentTheme === 'light' ? 'dark' : 'light'; }); },