1- import { ITabsRepository } from " ./tabs-repository-interface" ;
2- import { Tab } from " ../entity/tab" ;
3- import { injecStorage } from " ../storage/inject-storage" ;
4- import { isInBlackList } from " ../compositions/black-list" ;
5- import { StorageDeserializeParam } from " ../storage/storage-params" ;
6- import { todayLocalDate } from " ../utils/today" ;
1+ import { ITabsRepository } from ' ./tabs-repository-interface' ;
2+ import { Tab } from ' ../entity/tab' ;
3+ import { injecStorage } from ' ../storage/inject-storage' ;
4+ import { isInBlackList } from ' ../compositions/black-list' ;
5+ import { StorageDeserializeParam } from ' ../storage/storage-params' ;
6+ import { todayLocalDate } from ' ../utils/today' ;
77
88export class TabsRepository implements ITabsRepository {
99 private tabs : Tab [ ] ;
@@ -13,32 +13,30 @@ export class TabsRepository implements ITabsRepository {
1313 }
1414
1515 async initAsync ( ) {
16- this . tabs = ( await injecStorage ( ) . getDeserializeList (
17- StorageDeserializeParam . TABS
18- ) ) as Tab [ ] ;
16+ this . tabs = ( await injecStorage ( ) . getDeserializeList ( StorageDeserializeParam . TABS ) ) as Tab [ ] ;
1917 }
2018
2119 getTabs ( ) : Tab [ ] {
2220 return this . tabs ;
2321 }
2422
25- getTodayTabs ( ) : Tab [ ] {
23+ getTodayTabs ( ) : Tab [ ] {
2624 return this . tabs . filter ( x => x . days . find ( s => s . date === todayLocalDate ( ) ) ) ;
2725 }
2826
2927 getTab ( domain : string ) : Tab | undefined {
30- return this . tabs ?. find ( ( x ) => x . url === domain ) ;
28+ return this . tabs ?. find ( x => x . url === domain ) ;
3129 }
3230
3331 async addTab ( domain : string , favicon : string | undefined ) : Promise < Tab | undefined > {
3432 const tabFromStorage = this . getTab ( domain ) ;
3533 const isInBlackListFlag = await isInBlackList ( domain ) ;
3634
3735 if ( ! isInBlackListFlag && ! tabFromStorage ) {
38- const newTab = new Tab ( ) ;
39- newTab . init ( domain ) ;
40- this . tabs . push ( newTab ) ;
41- return newTab ;
36+ const newTab = new Tab ( ) ;
37+ newTab . init ( domain ) ;
38+ this . tabs . push ( newTab ) ;
39+ return newTab ;
4240 }
4341
4442 return undefined ;
0 commit comments