From 9384f5399da39e53855beb8e7f8ded1aa56bf72e Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 27 Dec 2022 14:36:33 +0900 Subject: rename: client -> frontend --- packages/client/src/theme-store.ts | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 packages/client/src/theme-store.ts (limited to 'packages/client/src/theme-store.ts') diff --git a/packages/client/src/theme-store.ts b/packages/client/src/theme-store.ts deleted file mode 100644 index fdc92ed793..0000000000 --- a/packages/client/src/theme-store.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { api } from '@/os'; -import { $i } from '@/account'; -import { Theme } from './scripts/theme'; - -const lsCacheKey = $i ? `themes:${$i.id}` : ''; - -export function getThemes(): Theme[] { - return JSON.parse(localStorage.getItem(lsCacheKey) || '[]'); -} - -export async function fetchThemes(): Promise { - if ($i == null) return; - - try { - const themes = await api('i/registry/get', { scope: ['client'], key: 'themes' }); - localStorage.setItem(lsCacheKey, JSON.stringify(themes)); - } catch (err) { - if (err.code === 'NO_SUCH_KEY') return; - throw err; - } -} - -export async function addTheme(theme: Theme): Promise { - await fetchThemes(); - const themes = getThemes().concat(theme); - await api('i/registry/set', { scope: ['client'], key: 'themes', value: themes }); - localStorage.setItem(lsCacheKey, JSON.stringify(themes)); -} - -export async function removeTheme(theme: Theme): Promise { - const themes = getThemes().filter(t => t.id !== theme.id); - await api('i/registry/set', { scope: ['client'], key: 'themes', value: themes }); - localStorage.setItem(lsCacheKey, JSON.stringify(themes)); -} -- cgit v1.2.3-freya