mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
separating background apis to their own classes
This commit is contained in:
37
src/background/tabs.background.ts
Normal file
37
src/background/tabs.background.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import MainBackground from './main.background';
|
||||
|
||||
export default class TabsBackground {
|
||||
private tabs: any;
|
||||
|
||||
constructor(private main: MainBackground) {
|
||||
this.tabs = chrome.tabs;
|
||||
}
|
||||
|
||||
async init() {
|
||||
if (!this.tabs) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.tabs.onActivated.addListener(async (activeInfo: any) => {
|
||||
await this.main.refreshBadgeAndMenu();
|
||||
});
|
||||
|
||||
this.tabs.onReplaced.addListener(async (addedTabId: any, removedTabId: any) => {
|
||||
if (this.main.onReplacedRan) {
|
||||
return;
|
||||
}
|
||||
this.main.onReplacedRan = true;
|
||||
await this.main.checkLoginsToAdd();
|
||||
await this.main.refreshBadgeAndMenu();
|
||||
});
|
||||
|
||||
this.tabs.onUpdated.addListener(async (tabId: any, changeInfo: any, tab: any) => {
|
||||
if (this.main.onUpdatedRan) {
|
||||
return;
|
||||
}
|
||||
this.main.onUpdatedRan = true;
|
||||
await this.main.checkLoginsToAdd();
|
||||
await this.main.refreshBadgeAndMenu();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user