Skip to content

Commit

Permalink
update modified time for keep version
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzhi713 committed Jan 14, 2021
1 parent b84564e commit 1058825
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/components/tabs/ExportView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,23 @@ export default class ExportView extends Store {
);
this.$forceUpdate();
}
async keepVersion(name: string, idx: number) {
async keepVersion(name: string) {
// make sure that the profile's modified time is changed to the latest so it can overwrite profiles on other synced devices
const _profile: SemesterStorage = JSON.parse(localStorage.getItem(name)!);
_profile.modified = new Date().toJSON();
const profile = JSON.stringify(_profile);
localStorage.setItem(name, profile);
const msg = await this.profile.uploadProfile([
{
name,
profile: localStorage.getItem(name)!,
profile,
new: true
}
]);
if (msg) this.noti.notify(msg);
if (msg) return this.noti.notify(msg);
localStorage.removeItem('backup-' + name);
this.noti.clear();
this.$forceUpdate();
}
async renameProfile(oldName: string, idx: number) {
const raw = localStorage.getItem(oldName);
Expand Down
2 changes: 1 addition & 1 deletion src/components/tabs/ExportView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<button
class="btn btn-outline-primary btn-sm"
title="Keep this version of the profile"
@click.stop="keepVersion(prof.name, idx)"
@click.stop="keepVersion(prof.name)"
>
Keep
</button>
Expand Down

0 comments on commit 1058825

Please sign in to comment.