Skip to content

Commit

Permalink
feat: auto fill upstash backup name
Browse files Browse the repository at this point in the history
  • Loading branch information
Yidadaa committed Sep 18, 2023
1 parent 83fed42 commit f1e7db6
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions app/store/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,29 @@ export interface WebDavConfig {

export type SyncStore = GetStoreState<typeof useSyncStore>;

export const useSyncStore = createPersistStore(
{
provider: ProviderType.WebDAV,
useProxy: true,
proxyUrl: corsPath(ApiPath.Cors),

webdav: {
endpoint: "",
username: "",
password: "",
},

upstash: {
endpoint: "",
username: STORAGE_KEY,
apiKey: "",
},
const DEFAULT_SYNC_STATE = {
provider: ProviderType.WebDAV,
useProxy: true,
proxyUrl: corsPath(ApiPath.Cors),

webdav: {
endpoint: "",
username: "",
password: "",
},

lastSyncTime: 0,
lastProvider: "",
upstash: {
endpoint: "",
username: STORAGE_KEY,
apiKey: "",
},

lastSyncTime: 0,
lastProvider: "",
};

export const useSyncStore = createPersistStore(
DEFAULT_SYNC_STATE,
(set, get) => ({
coundSync() {
const config = get()[get().provider];
Expand Down Expand Up @@ -108,6 +110,16 @@ export const useSyncStore = createPersistStore(
}),
{
name: StoreKey.Sync,
version: 1,
version: 1.1,

migrate(persistedState, version) {
const newState = persistedState as typeof DEFAULT_SYNC_STATE;

if (version < 1.1) {
newState.upstash.username = STORAGE_KEY;
}

return newState as any;
},
},
);

0 comments on commit f1e7db6

Please sign in to comment.