@@ -6,23 +6,22 @@ import { isValidPage } from '../compositions/valid-page';
66import { isInBlackList } from "../compositions/black-list" ;
77import { extractHostname } from "../compositions/extract-hostname" ;
88import { addInterval , closeInterval } from "../compositions/daily-intervals" ;
9+ import { ActiveTab } from "../compositions/activeTab"
910
1011export class TabsRepository implements ITabsRepository {
1112 private tabs : Tab [ ] ;
12- private currentTabDomain : string | null ;
13+ private activeTab = ActiveTab . getInstance ( ) ;
1314
1415 constructor ( ) {
1516 this . tabs = [ ] ;
16- this . currentTabDomain = null ;
1717 }
1818
1919 async initAsync ( ) {
2020 this . tabs = await injecStorage ( ) . getTabs ( ) ;
2121 }
2222
2323 getTab ( domain : string ) : Tab | undefined {
24- const tab = this . tabs ?. find ( x => x . url === domain ) ;
25- return ! tab ? tab : undefined ;
24+ return this . tabs ?. find ( x => x . url === domain ) ;
2625 }
2726
2827 async addTab ( tab : Browser . Tabs . Tab ) : Promise < void > {
@@ -42,17 +41,17 @@ export class TabsRepository implements ITabsRepository {
4241 }
4342 else {
4443 tabFromStorage . incCounter ( ) ;
45- if ( this . currentTabDomain != domain ) this . setCurrentActiveTab ( domain ) ;
46- await closeInterval ( this . currentTabDomain ) ;
47- await addInterval ( this . currentTabDomain ) ;
44+ if ( this . activeTab . getActiveTab ( ) != domain ) this . setCurrentActiveTab ( domain ) ;
45+ await closeInterval ( this . activeTab . getActiveTab ( ) ) ;
46+ await addInterval ( this . activeTab . getActiveTab ( ) ) ;
4847 }
4948 }
50- else await closeInterval ( this . currentTabDomain ) ;
49+ else await closeInterval ( this . activeTab . getActiveTab ( ) ) ;
5150 }
52- } else await closeInterval ( this . currentTabDomain ) ;
51+ } else await closeInterval ( this . activeTab . getActiveTab ( ) ) ;
5352 }
5453
5554 private setCurrentActiveTab ( domain :string ) {
56- this . currentTabDomain = domain ;
55+ this . activeTab . setActiveTab ( domain ) ;
5756 }
5857}
0 commit comments