mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 09:43:23 +00:00
Move notificationQueue from main into notification.background
This commit is contained in:
@@ -127,7 +127,6 @@ export default class MainBackground {
|
||||
onUpdatedRan: boolean;
|
||||
onReplacedRan: boolean;
|
||||
loginToAutoFill: any = null;
|
||||
notificationQueue: any[] = [];
|
||||
|
||||
private commandsBackground: CommandsBackground;
|
||||
private contextMenusBackground: ContextMenusBackground;
|
||||
@@ -250,7 +249,7 @@ export default class MainBackground {
|
||||
this.notificationBackground = new NotificationBackground(this, this.autofillService, this.cipherService,
|
||||
this.storageService, this.vaultTimeoutService, this.policyService, this.folderService);
|
||||
|
||||
this.tabsBackground = new TabsBackground(this);
|
||||
this.tabsBackground = new TabsBackground(this, this.notificationBackground);
|
||||
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService, this.passwordGenerationService,
|
||||
this.platformUtilsService, this.vaultTimeoutService, this.eventService, this.totpService);
|
||||
this.idleBackground = new IdleBackground(this.vaultTimeoutService, this.storageService,
|
||||
@@ -292,7 +291,6 @@ export default class MainBackground {
|
||||
setTimeout(async () => {
|
||||
await this.environmentService.setUrlsFromStorage();
|
||||
await this.setIcon();
|
||||
this.cleanupNotificationQueue();
|
||||
this.fullSync(true);
|
||||
setTimeout(() => this.notificationsService.init(), 2500);
|
||||
resolve();
|
||||
@@ -390,22 +388,6 @@ export default class MainBackground {
|
||||
}, options);
|
||||
}
|
||||
|
||||
async checkNotificationQueue(tab: any = null): Promise<any> {
|
||||
if (this.notificationQueue.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tab != null) {
|
||||
this.doNotificationQueueCheck(tab);
|
||||
return;
|
||||
}
|
||||
|
||||
const currentTab = await BrowserApi.getTabFromCurrentWindow();
|
||||
if (currentTab != null) {
|
||||
this.doNotificationQueueCheck(currentTab);
|
||||
}
|
||||
}
|
||||
|
||||
async openPopup() {
|
||||
// Chrome APIs cannot open popup
|
||||
|
||||
@@ -657,49 +639,6 @@ export default class MainBackground {
|
||||
return title.replace(/&/g, '&&');
|
||||
}
|
||||
|
||||
private cleanupNotificationQueue() {
|
||||
for (let i = this.notificationQueue.length - 1; i >= 0; i--) {
|
||||
if (this.notificationQueue[i].expires < new Date()) {
|
||||
this.notificationQueue.splice(i, 1);
|
||||
}
|
||||
}
|
||||
setTimeout(() => this.cleanupNotificationQueue(), 2 * 60 * 1000); // check every 2 minutes
|
||||
}
|
||||
|
||||
private doNotificationQueueCheck(tab: any) {
|
||||
if (tab == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tabDomain = Utils.getDomain(tab.url);
|
||||
if (tabDomain == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.notificationQueue.length; i++) {
|
||||
if (this.notificationQueue[i].tabId !== tab.id || this.notificationQueue[i].domain !== tabDomain) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.notificationQueue[i].type === 'addLogin') {
|
||||
BrowserApi.tabSendMessageData(tab, 'openNotificationBar', {
|
||||
type: 'add',
|
||||
typeData: {
|
||||
isVaultLocked: this.notificationQueue[i].wasVaultLocked,
|
||||
},
|
||||
});
|
||||
} else if (this.notificationQueue[i].type === 'changePassword') {
|
||||
BrowserApi.tabSendMessageData(tab, 'openNotificationBar', {
|
||||
type: 'change',
|
||||
typeData: {
|
||||
isVaultLocked: this.notificationQueue[i].wasVaultLocked,
|
||||
},
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private async fullSync(override: boolean = false) {
|
||||
const syncInternal = 6 * 60 * 60 * 1000; // 6 hours
|
||||
const lastSync = await this.syncService.getLastSync();
|
||||
|
||||
Reference in New Issue
Block a user