1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

move last sync and generapte password out to other commands

This commit is contained in:
Kyle Spearrin
2018-05-16 13:53:12 -04:00
parent 8a337893da
commit 3a53e2d208
4 changed files with 66 additions and 50 deletions

View File

@@ -3,16 +3,29 @@ import * as program from 'commander';
import { SyncService } from 'jslib/abstractions/sync.service';
import { Response } from '../models/response';
import { MessageResponse } from '../models/response/messageResponse';
import { StringResponse } from '../models/response/stringResponse';
export class SyncCommand {
constructor(private syncService: SyncService) { }
async run(cmd: program.Command): Promise<Response> {
if (cmd.last || false) {
return await this.getLastSync();
}
try {
const result = await this.syncService.fullSync(cmd.force || false);
return Response.success();
const res = new MessageResponse('Syncing complete.', null);
return Response.success(res);
} catch (e) {
return Response.error(e);
}
}
private async getLastSync() {
const lastSyncDate = await this.syncService.getLastSync();
const res = new StringResponse(lastSyncDate == null ? null : lastSyncDate.toISOString());
return Response.success(res);
}
}