Files
standardnotes-app-web/app/assets/javascripts/directives/views/syncResolutionMenu.js
Mo Bitar 13dd41b9ab WIP
2020-02-05 17:00:11 -06:00

58 lines
1.2 KiB
JavaScript

import template from '%/directives/sync-resolution-menu.pug';
class SyncResolutionMenuCtrl {
/* @ngInject */
constructor(
$timeout,
archiveManager,
application
) {
this.$timeout = $timeout;
this.archiveManager = archiveManager;
this.application = application;
this.status = {};
}
downloadBackup(encrypted) {
this.archiveManager.downloadBackup(encrypted);
this.status.backupFinished = true;
}
skipBackup() {
this.status.backupFinished = true;
}
async performSyncResolution() {
this.status.resolving = true;
await this.application.resolveOutOfSync();
this.$timeout(() => {
this.status.resolving = false;
this.status.attemptedResolution = true;
if (this.application.getSyncStatus().isOutOfSync()) {
this.status.fail = true;
} else {
this.status.success = true;
}
});
}
close() {
this.$timeout(() => {
this.closeFunction()();
});
}
}
export class SyncResolutionMenu {
constructor() {
this.restrict = 'E';
this.template = template;
this.controller = SyncResolutionMenuCtrl;
this.controllerAs = 'ctrl';
this.bindToController = true;
this.scope = {
closeFunction: '&'
};
}
}