fix storage hook

This commit is contained in:
Gabe Yuan
2023-09-17 21:50:17 +08:00
parent 8935ced75a
commit 1553559b1a
4 changed files with 35 additions and 20 deletions

View File

@@ -5,16 +5,13 @@ import { createContext, useCallback, useContext, useMemo } from "react";
import { debounce } from "../libs/utils";
const SettingContext = createContext({
setting: {},
setting: null,
updateSetting: async () => {},
reloadSetting: async () => {},
});
export function SettingProvider({ children }) {
const { data, update, reload, loading } = useStorage(
STOKEY_SETTING,
DEFAULT_SETTING
);
const { data, update, reload } = useStorage(STOKEY_SETTING, DEFAULT_SETTING);
const syncSetting = useMemo(
() =>
@@ -32,7 +29,7 @@ export function SettingProvider({ children }) {
[update, syncSetting]
);
if (loading) {
if (!data) {
return;
}