fix data sync

This commit is contained in:
Gabe Yuan
2023-07-31 15:08:51 +08:00
parent 2aef159d9d
commit fed0f6849a
18 changed files with 237 additions and 145 deletions

20
src/hooks/Sync.js Normal file
View File

@@ -0,0 +1,20 @@
import { useCallback } from "react";
import { STOKEY_SYNC } from "../config";
import storage from "../libs/storage";
import { useStorages } from "./Storage";
/**
* sync hook
* @returns
*/
export function useSync() {
const storages = useStorages();
const opt = storages?.[STOKEY_SYNC];
const update = useCallback(async (obj) => {
await storage.putObj(STOKEY_SYNC, obj);
}, []);
return {
opt,
update,
};
}