Skip to content

Commit

Permalink
fix: migration
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed Feb 5, 2024
1 parent 051a187 commit 43037fd
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions src/store/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { initialActivityState } from '../slices/activity';
import { initialChecksState } from '../slices/checks';
import { initialWidgetsState } from '../slices/widgets';
import cloneDeep from 'lodash/cloneDeep';
import { EBackupCategories } from '../utils/backup';

const migrations = {
0: (state): PersistedState => {
Expand Down Expand Up @@ -444,11 +444,41 @@ const migrations = {
};
}

// force backup
const backup = cloneDeep(initialBackupState);
for (const key in initialBackupState) {
backup[key].synced = backup[key].required - 10;
}
const now = Date.now();
const old = state.backup;

const backup = {
[EBackupCategories.widgets]: {
required: old.remoteWidgetsBackupSyncRequired ?? now - 1000,
synced: old.remoteWidgetsBackupSynced ?? now,
running: false,
},
[EBackupCategories.settings]: {
required: old.remoteSettingsBackupSyncRequired ?? now - 1000,
synced: old.remoteSettingsBackupSynced ?? now,
running: false,
},
[EBackupCategories.metadata]: {
required: old.remoteMetadataBackupSyncRequired ?? now - 1000,
synced: old.remoteMetadataBackupSynced ?? now,
running: false,
},
[EBackupCategories.blocktank]: {
required: old.remoteBlocktankBackupSyncRequired ?? now - 1000,
synced: old.remoteBlocktankBackupSynced ?? now,
running: false,
},
[EBackupCategories.slashtags]: {
required: old.remoteSlashtagsBackupSyncRequired ?? now - 1000,
synced: old.remoteSlashtagsBackupLastSync ?? now,
running: false,
},
[EBackupCategories.ldkActivity]: {
required: old.remoteLdkActivityBackupLastSync ?? now - 1000,
synced: old.remoteSlashtagsBackupLastSync ?? now,
running: false,
},
};

return {
...state,
Expand Down

0 comments on commit 43037fd

Please sign in to comment.