Skip to content

Commit 5f76886

Browse files
committed
Add tabs repository
1 parent 0f0ecd7 commit 5f76886

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ITabsRepository } from "./tabs-repository-interface";
2+
import { TabsRepository } from "./tabs-repository";
3+
4+
export async function injectTabsRepository(): Promise<ITabsRepository> {
5+
return await TabsRepository.Create();
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Tab } from "../storage/tab";
2+
import Browser from 'webextension-polyfill';
3+
4+
export interface ITabsRepository {
5+
getTab(domain:string): Promise<Tab>;
6+
addTab(value:Browser.Tabs.Tab): Promise<void>;
7+
}

src/repository/tabs-repository.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ITabsRepository } from "./tabs-repository-interface";
2+
import { Tab } from "../storage/tab";
3+
import Browser from 'webextension-polyfill';
4+
import { injecStorage } from "../storage/inject-storage";
5+
6+
export class TabsRepository implements ITabsRepository {
7+
static tabs: Tab[];
8+
9+
constructor(){}
10+
11+
static async Create(): Promise<TabsRepository> {
12+
const instance = new TabsRepository();
13+
this.tabs = await injecStorage().getTabs();
14+
return instance;
15+
}
16+
17+
getTab(domain: string): Promise<Tab> {
18+
throw new Error("Method not implemented.");
19+
}
20+
21+
addTab(value: Browser.Tabs.Tab): Promise<void> {
22+
throw new Error("Method not implemented.");
23+
}
24+
}

0 commit comments

Comments
 (0)