Skip to content

Commit

Permalink
fix(congregation): update source material when backup instead of over…
Browse files Browse the repository at this point in the history
…write
  • Loading branch information
rhahao committed Feb 26, 2023
1 parent 8323d9c commit 46e3bc6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/features/backupRestore/BackupMain.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const BackupMain = ({ handleCreateBackup, handleClose, handleRestoreBackup, open
<>
{hasBackup && (
<Typography>
{t('lastCongBackup', {
{t(action === 'backup' ? 'lastCongBackup' : 'restoreConfirmation', {
backup_person: backup.by,
backup_date: dateFormat(new Date(backup.date), shortDateFormat),
})}
Expand Down
1 change: 1 addition & 0 deletions src/features/userAutoLogin/UserAutoLogin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const UserAutoLogin = () => {
obj.cong_number = cong_number;
obj.pocket_members = pocket_members;
obj.cong_role = cong_role;
obj.account_type = 'vip';
await dbUpdateAppSettings(obj);
setPocketMembers(pocket_members);
return;
Expand Down
7 changes: 5 additions & 2 deletions src/indexedDb/dbUtility.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,12 @@ export const dbRestoreCongregationBackup = async (

// restore source materials
const oldSources = await appDb.src.toArray();
await appDb.src.clear();
for await (const src of cong_sourceMaterial) {
await appDb.src.add(src, src.weekOf);
const isSrcExist = oldSources.find((source) => source.weekOf === src.weekOf);

if (!isSrcExist) {
await appDb.src.add(src, src.weekOf);
}

// restore keepOverride if qualified
const newKeepOverride = src.keepOverride || undefined;
Expand Down

0 comments on commit 46e3bc6

Please sign in to comment.