run cloud sync on startup

This commit is contained in:
Wang Guan
2024-10-19 18:58:35 +09:00
parent 06f897f32f
commit 93ad218d68
2 changed files with 31 additions and 5 deletions

View File

@@ -27,18 +27,22 @@ const DEFAULT_SYNC_STATE = {
useProxy: true,
proxyUrl: ApiPath.Cors as string,
webdav: {
[ProviderType.WebDAV]: {
endpoint: "",
username: "",
password: "",
},
upstash: {
[ProviderType.UpStash]: {
endpoint: "",
username: STORAGE_KEY,
apiKey: "",
},
autoSync: {
onStart: true,
},
lastSyncTime: 0,
lastProvider: "",
};
@@ -46,7 +50,7 @@ const DEFAULT_SYNC_STATE = {
export const useSyncStore = createPersistStore(
DEFAULT_SYNC_STATE,
(set, get) => ({
cloudSync() {
cloudSync(): boolean {
const config = get()[get().provider];
return Object.values(config).every((c) => c.toString().length > 0);
},