From cdfd54ed99087dc4a7a3fd13865849ff9ce9e8ba Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 19 May 2019 21:34:08 +0900 Subject: Use TSyringe on background script --- src/background/repositories/BookmarkRepository.ts | 3 +++ src/background/repositories/BrowserSettingRepository.ts | 2 ++ src/background/repositories/CompletionsRepository.ts | 3 +++ src/background/repositories/FindRepository.ts | 2 ++ src/background/repositories/MarkRepository.ts | 2 ++ src/background/repositories/PersistentSettingRepository.ts | 2 ++ src/background/repositories/SettingRepository.ts | 2 ++ 7 files changed, 16 insertions(+) (limited to 'src/background/repositories') diff --git a/src/background/repositories/BookmarkRepository.ts b/src/background/repositories/BookmarkRepository.ts index b4da509..d266ae6 100644 --- a/src/background/repositories/BookmarkRepository.ts +++ b/src/background/repositories/BookmarkRepository.ts @@ -1,3 +1,6 @@ +import { injectable } from 'tsyringe'; + +@injectable() export default class BookmarkRepository { async create( title: string, url: string diff --git a/src/background/repositories/BrowserSettingRepository.ts b/src/background/repositories/BrowserSettingRepository.ts index 33b35dd..9cfb35e 100644 --- a/src/background/repositories/BrowserSettingRepository.ts +++ b/src/background/repositories/BrowserSettingRepository.ts @@ -1,3 +1,4 @@ +import { injectable } from 'tsyringe'; import * as urls from '../../shared/urls'; declare namespace browser.browserSettings.homepageOverride { @@ -16,6 +17,7 @@ declare namespace browser.browserSettings.homepageOverride { function get(param: object): Promise; } +@injectable() export default class BrowserSettingRepository { async getHomepageUrls(): Promise { let { value } = await browser.browserSettings.homepageOverride.get({}); diff --git a/src/background/repositories/CompletionsRepository.ts b/src/background/repositories/CompletionsRepository.ts index 18af587..dfdbc27 100644 --- a/src/background/repositories/CompletionsRepository.ts +++ b/src/background/repositories/CompletionsRepository.ts @@ -1,6 +1,9 @@ +import { injectable } from 'tsyringe'; + type Tab = browser.tabs.Tab; type BookmarkTreeNode = browser.bookmarks.BookmarkTreeNode; +@injectable() export default class CompletionsRepository { async queryBookmarks(keywords: string): Promise { let items = await browser.bookmarks.search({ query: keywords }); diff --git a/src/background/repositories/FindRepository.ts b/src/background/repositories/FindRepository.ts index bf286e6..6a087f5 100644 --- a/src/background/repositories/FindRepository.ts +++ b/src/background/repositories/FindRepository.ts @@ -1,7 +1,9 @@ +import { injectable } from 'tsyringe'; import MemoryStorage from '../infrastructures/MemoryStorage'; const FIND_KEYWORD_KEY = 'find-keyword'; +@injectable() export default class FindRepository { private cache: MemoryStorage; diff --git a/src/background/repositories/MarkRepository.ts b/src/background/repositories/MarkRepository.ts index 69c85f6..c106fff 100644 --- a/src/background/repositories/MarkRepository.ts +++ b/src/background/repositories/MarkRepository.ts @@ -1,8 +1,10 @@ +import { injectable } from 'tsyringe'; import MemoryStorage from '../infrastructures/MemoryStorage'; import GlobalMark from '../domains/GlobalMark'; const MARK_KEY = 'mark'; +@injectable() export default class MarkRepository { private cache: MemoryStorage; diff --git a/src/background/repositories/PersistentSettingRepository.ts b/src/background/repositories/PersistentSettingRepository.ts index ff882a5..927bce9 100644 --- a/src/background/repositories/PersistentSettingRepository.ts +++ b/src/background/repositories/PersistentSettingRepository.ts @@ -1,5 +1,7 @@ +import { injectable } from 'tsyringe'; import SettingData from '../../shared/SettingData'; +@injectable() export default class SettingRepository { async load(): Promise { let { settings } = await browser.storage.local.get('settings'); diff --git a/src/background/repositories/SettingRepository.ts b/src/background/repositories/SettingRepository.ts index eb83a2c..2f159e5 100644 --- a/src/background/repositories/SettingRepository.ts +++ b/src/background/repositories/SettingRepository.ts @@ -1,9 +1,11 @@ +import { injectable } from 'tsyringe'; import MemoryStorage from '../infrastructures/MemoryStorage'; import Settings from '../../shared/Settings'; import * as PropertyDefs from '../../shared/property-defs'; const CACHED_SETTING_KEY = 'setting'; +@injectable() export default class SettingRepository { private cache: MemoryStorage; -- cgit v1.2.3