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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user