2017-12-07 21:06:37 +01:00
|
|
|
import MainBackground from './main.background';
|
|
|
|
|
|
|
|
export default class TabsBackground {
|
|
|
|
private tabs: any;
|
|
|
|
|
2019-08-21 15:42:34 +02:00
|
|
|
constructor(private main: MainBackground) {
|
|
|
|
this.tabs = chrome.tabs;
|
2017-12-07 21:06:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2018-08-01 05:24:11 +02:00
|
|
|
await this.main.checkNotificationQueue();
|
2017-12-07 21:06:37 +01:00
|
|
|
await this.main.refreshBadgeAndMenu();
|
|
|
|
});
|
|
|
|
|
|
|
|
this.tabs.onUpdated.addListener(async (tabId: any, changeInfo: any, tab: any) => {
|
|
|
|
if (this.main.onUpdatedRan) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.main.onUpdatedRan = true;
|
2018-08-01 05:24:11 +02:00
|
|
|
await this.main.checkNotificationQueue();
|
2017-12-07 21:06:37 +01:00
|
|
|
await this.main.refreshBadgeAndMenu();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|