From 45a85ab12b25b7355a194fa8cfda3447e3403c67 Mon Sep 17 00:00:00 2001 From: linonetwo Date: Wed, 10 Jan 2024 23:57:13 +0800 Subject: [PATCH] refactor: remove server store index, and storage that is default value --- src/options/Options.tsx | 4 ++-- src/shared/index.ts | 2 +- src/shared/preferences/store.ts | 4 +--- src/shared/server/index.ts | 2 -- src/shared/server/store.ts | 4 +--- 5 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 src/shared/server/index.ts diff --git a/src/options/Options.tsx b/src/options/Options.tsx index 271ae46..09b917b 100644 --- a/src/options/Options.tsx +++ b/src/options/Options.tsx @@ -1,5 +1,5 @@ import { useTranslation } from 'react-i18next'; -import { Servers } from '../shared/server'; +import { ServersOptions } from './Servers'; import { TiddlerOptions } from './Tiddler'; export function Options() { @@ -8,7 +8,7 @@ export function Options() {

{t('Options')}

- +
diff --git a/src/shared/index.ts b/src/shared/index.ts index 0fbaf31..0ea768e 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -1,6 +1,6 @@ /* eslint-disable unicorn/prefer-top-level-await */ import { preferenceStoreReadyPromise } from './preferences/store'; -import { serverStoreReadyPromise } from './server'; +import { serverStoreReadyPromise } from './server/store'; export const storeReadyPromise = Promise.race([ serverStoreReadyPromise, diff --git a/src/shared/preferences/store.ts b/src/shared/preferences/store.ts index f371474..946bbb8 100644 --- a/src/shared/preferences/store.ts +++ b/src/shared/preferences/store.ts @@ -1,8 +1,7 @@ /* eslint-disable @typescript-eslint/strict-boolean-expressions */ -import { localStorage } from 'redux-persist-webextension-storage'; import { wrapStore } from 'webext-zustand'; import { create } from 'zustand'; -import { createJSONStorage, devtools, persist } from 'zustand/middleware'; +import { devtools, persist } from 'zustand/middleware'; import { immer } from 'zustand/middleware/immer'; import { IContent } from '../../popup/hooks/useTransformFormat'; @@ -46,7 +45,6 @@ export const usePreferenceStore = create()( }), { name: 'preference-storage', - storage: createJSONStorage(() => localStorage), }, ), )), diff --git a/src/shared/server/index.ts b/src/shared/server/index.ts deleted file mode 100644 index 414694f..0000000 --- a/src/shared/server/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { ServersOptions as Servers } from '../../options/Servers'; -export { serverStoreReadyPromise, useServerStore } from './store'; diff --git a/src/shared/server/store.ts b/src/shared/server/store.ts index 811b592..84cd5fc 100644 --- a/src/shared/server/store.ts +++ b/src/shared/server/store.ts @@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/strict-boolean-expressions */ -import { localStorage } from 'redux-persist-webextension-storage'; import cloneDeepRaw from 'rfdc'; import { wrapStore } from 'webext-zustand'; import { create } from 'zustand'; -import { createJSONStorage, devtools, persist } from 'zustand/middleware'; +import { devtools, persist } from 'zustand/middleware'; import { immer } from 'zustand/middleware/immer'; const cloneDeep = cloneDeepRaw(); @@ -98,7 +97,6 @@ export const useServerStore = create()( }), { name: 'server-storage', - storage: createJSONStorage(() => localStorage), }, ), )),