1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-07-04 11:55:58 +02:00

[PM-6426] Fixing issues identified in code review

This commit is contained in:
Cesar Gonzalez 2024-05-07 09:08:28 -05:00
parent a0da892407
commit 84444ebf17
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
11 changed files with 18 additions and 25 deletions

View File

@ -17,7 +17,7 @@ export class GeneratePasswordToClipboardCommand {
private autofillSettingsService: AutofillSettingsServiceAbstraction, private autofillSettingsService: AutofillSettingsServiceAbstraction,
private taskSchedulerService?: BrowserTaskSchedulerService, private taskSchedulerService?: BrowserTaskSchedulerService,
) { ) {
void this.taskSchedulerService?.registerTaskHandler( this.taskSchedulerService?.registerTaskHandler(
ScheduledTaskNames.generatePasswordClearClipboardTimeout, ScheduledTaskNames.generatePasswordClearClipboardTimeout,
() => ClearClipboard.run(), () => ClearClipboard.run(),
); );

View File

@ -516,7 +516,7 @@ export default class MainBackground {
this.logService, this.logService,
this.stateProvider, this.stateProvider,
); );
void this.taskSchedulerService.registerTaskHandler( this.taskSchedulerService.registerTaskHandler(
ScheduledTaskNames.scheduleNextSyncInterval, ScheduledTaskNames.scheduleNextSyncInterval,
() => this.fullSync(), () => this.fullSync(),
); );

View File

@ -29,8 +29,11 @@ export class BrowserTaskSchedulerServiceImplementation
private activeAlarmsState: GlobalState<ActiveAlarm[]>; private activeAlarmsState: GlobalState<ActiveAlarm[]>;
readonly activeAlarms$: Observable<ActiveAlarm[]>; readonly activeAlarms$: Observable<ActiveAlarm[]>;
constructor(logService: LogService, stateProvider: StateProvider) { constructor(
super(logService, stateProvider); logService: LogService,
private stateProvider: StateProvider,
) {
super(logService);
this.activeAlarmsState = this.stateProvider.getGlobal(ACTIVE_ALARMS); this.activeAlarmsState = this.stateProvider.getGlobal(ACTIVE_ALARMS);
this.activeAlarms$ = this.activeAlarmsState.state$.pipe( this.activeAlarms$ = this.activeAlarmsState.state$.pipe(
@ -420,7 +423,7 @@ export class BrowserTaskSchedulerServiceImplementation
* *
* @param alarmName - The name of the alarm to get. * @param alarmName - The name of the alarm to get.
*/ */
private async getAlarm(alarmName: string): Promise<chrome.alarms.Alarm> { private getAlarm(alarmName: string): Promise<chrome.alarms.Alarm> {
if (this.isNonChromeEnvironment()) { if (this.isNonChromeEnvironment()) {
return browser.alarms.get(alarmName); return browser.alarms.get(alarmName);
} }

View File

@ -121,7 +121,7 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
this.authRequestPushNotificationState = this.stateProvider.get( this.authRequestPushNotificationState = this.stateProvider.get(
AUTH_REQUEST_PUSH_NOTIFICATION_KEY, AUTH_REQUEST_PUSH_NOTIFICATION_KEY,
); );
void this.taskSchedulerService?.registerTaskHandler( this.taskSchedulerService?.registerTaskHandler(
ScheduledTaskNames.loginStrategySessionTimeout, ScheduledTaskNames.loginStrategySessionTimeout,
() => this.clearCache(), () => this.clearCache(),
); );

View File

@ -1,7 +1,4 @@
import { ScheduledTaskName } from "../enums/scheduled-task-name.enum"; import { ScheduledTaskName } from "../enums/scheduled-task-name.enum";
import { StateProvider } from "../state";
import { LogService } from "./log.service";
export type TaskIdentifier = { export type TaskIdentifier = {
taskName?: ScheduledTaskName; taskName?: ScheduledTaskName;
@ -10,10 +7,6 @@ export type TaskIdentifier = {
}; };
export abstract class TaskSchedulerService { export abstract class TaskSchedulerService {
constructor(
protected logService: LogService,
protected stateProvider: StateProvider,
) {}
protected taskHandlers: Map<string, () => void>; protected taskHandlers: Map<string, () => void>;
abstract setTimeout( abstract setTimeout(
taskName: ScheduledTaskName, taskName: ScheduledTaskName,

View File

@ -1,11 +1,10 @@
import { LogService } from "../abstractions/log.service"; import { LogService } from "../abstractions/log.service";
import { TaskIdentifier, TaskSchedulerService } from "../abstractions/task-scheduler.service"; import { TaskIdentifier, TaskSchedulerService } from "../abstractions/task-scheduler.service";
import { ScheduledTaskName } from "../enums/scheduled-task-name.enum"; import { ScheduledTaskName } from "../enums/scheduled-task-name.enum";
import { StateProvider } from "../state";
export class DefaultTaskSchedulerService extends TaskSchedulerService { export class DefaultTaskSchedulerService extends TaskSchedulerService {
constructor(logService: LogService, stateProvider: StateProvider) { constructor(protected logService: LogService) {
super(logService, stateProvider); super();
this.taskHandlers = new Map(); this.taskHandlers = new Map();
} }

View File

@ -32,7 +32,7 @@ export class SystemService implements SystemServiceAbstraction {
private accountService: AccountService, private accountService: AccountService,
private taskSchedulerService?: TaskSchedulerService, private taskSchedulerService?: TaskSchedulerService,
) { ) {
void this.taskSchedulerService?.registerTaskHandler( this.taskSchedulerService?.registerTaskHandler(
ScheduledTaskNames.systemClearClipboardTimeout, ScheduledTaskNames.systemClearClipboardTimeout,
() => this.clearPendingClipboard(), () => this.clearPendingClipboard(),
); );

View File

@ -23,9 +23,8 @@ export class EventUploadService implements EventUploadServiceAbstraction {
private authService: AuthService, private authService: AuthService,
private taskSchedulerService?: TaskSchedulerService, private taskSchedulerService?: TaskSchedulerService,
) { ) {
void this.taskSchedulerService?.registerTaskHandler( this.taskSchedulerService?.registerTaskHandler(ScheduledTaskNames.eventUploadsInterval, () =>
ScheduledTaskNames.eventUploadsInterval, this.uploadEvents(),
() => this.uploadEvents(),
); );
} }

View File

@ -46,7 +46,7 @@ export class NotificationsService implements NotificationsServiceAbstraction {
private messagingService: MessagingService, private messagingService: MessagingService,
private taskSchedulerService?: TaskSchedulerService, private taskSchedulerService?: TaskSchedulerService,
) { ) {
void this.taskSchedulerService?.registerTaskHandler( this.taskSchedulerService?.registerTaskHandler(
ScheduledTaskNames.notificationsReconnectTimeout, ScheduledTaskNames.notificationsReconnectTimeout,
() => this.reconnect(this.isSyncingOnReconnect), () => this.reconnect(this.isSyncingOnReconnect),
); );

View File

@ -40,7 +40,7 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction {
private loggedOutCallback: (expired: boolean, userId?: string) => Promise<void> = null, private loggedOutCallback: (expired: boolean, userId?: string) => Promise<void> = null,
private taskSchedulerService?: TaskSchedulerService, private taskSchedulerService?: TaskSchedulerService,
) { ) {
void this.taskSchedulerService?.registerTaskHandler( this.taskSchedulerService?.registerTaskHandler(
ScheduledTaskNames.vaultTimeoutCheckInterval, ScheduledTaskNames.vaultTimeoutCheckInterval,
() => this.checkVaultTimeout(), () => this.checkVaultTimeout(),
); );

View File

@ -63,9 +63,8 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction {
private taskSchedulerService?: TaskSchedulerService, private taskSchedulerService?: TaskSchedulerService,
private logService?: LogService, private logService?: LogService,
) { ) {
void this.taskSchedulerService?.registerTaskHandler( this.taskSchedulerService?.registerTaskHandler(ScheduledTaskNames.fido2ClientAbortTimeout, () =>
ScheduledTaskNames.fido2ClientAbortTimeout, this.timeoutAbortController?.abort(),
() => this.timeoutAbortController?.abort(),
); );
} }