mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 17:23:37 +00:00
[TypeScript] Settings module (#398)
* Convert settings to TypeScript. * Simplify loadSettings using await. * Re-write save feature settings. * Minor fixes.
This commit is contained in:
committed by
Kyle Spearrin
parent
7c525d3f3a
commit
78c4ea7ecb
47
src/popup/app/settings/sync.component.ts
Normal file
47
src/popup/app/settings/sync.component.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import * as template from './sync.component.html';
|
||||
|
||||
class SyncController {
|
||||
i18n: any;
|
||||
lastSync = '--';
|
||||
loading = false;
|
||||
|
||||
constructor(private syncService: any, private toastr: any, private $analytics: any, private i18nService: any) {
|
||||
this.i18n = i18nService;
|
||||
|
||||
this.setLastSync();
|
||||
}
|
||||
|
||||
sync() {
|
||||
this.loading = true;
|
||||
this.syncService
|
||||
.fullSync(true)
|
||||
.then((success: boolean) => {
|
||||
this.loading = false;
|
||||
if (success) {
|
||||
this.setLastSync();
|
||||
this.$analytics.eventTrack('Synced Full');
|
||||
this.toastr.success(this.i18nService.syncingComplete);
|
||||
} else {
|
||||
this.toastr.error(this.i18nService.syncingFailed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setLastSync() {
|
||||
this.syncService
|
||||
.getLastSync()
|
||||
.then((lastSync: any) => {
|
||||
if (lastSync) {
|
||||
this.lastSync = lastSync.toLocaleDateString() + ' ' + lastSync.toLocaleTimeString();
|
||||
} else {
|
||||
this.lastSync = this.i18nService.never;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const SyncComponent = {
|
||||
bindings: {},
|
||||
controller: SyncController,
|
||||
template,
|
||||
};
|
||||
Reference in New Issue
Block a user