diff options
Diffstat (limited to 'src/background/repositories')
-rw-r--r-- | src/background/repositories/BookmarkRepository.ts | 9 | ||||
-rw-r--r-- | src/background/repositories/BrowserSettingRepository.ts | 15 | ||||
-rw-r--r-- | src/background/repositories/CachedSettingRepository.ts | 39 | ||||
-rw-r--r-- | src/background/repositories/FindRepository.ts | 7 | ||||
-rw-r--r-- | src/background/repositories/MarkRepository.ts | 9 | ||||
-rw-r--r-- | src/background/repositories/RepeatRepository.ts | 8 | ||||
-rw-r--r-- | src/background/repositories/SettingRepository.ts | 12 |
7 files changed, 48 insertions, 51 deletions
diff --git a/src/background/repositories/BookmarkRepository.ts b/src/background/repositories/BookmarkRepository.ts index 0d2a1fc..e6e55c9 100644 --- a/src/background/repositories/BookmarkRepository.ts +++ b/src/background/repositories/BookmarkRepository.ts @@ -1,17 +1,18 @@ -import { injectable } from 'tsyringe'; +import { injectable } from "tsyringe"; @injectable() export default class BookmarkRepository { async create( - title: string, url: string + title: string, + url: string ): Promise<browser.bookmarks.BookmarkTreeNode> { const item = await browser.bookmarks.create({ - type: 'bookmark', + type: "bookmark", title, url, }); if (!item) { - throw new Error('Could not create a bookmark'); + throw new Error("Could not create a bookmark"); } return item; } diff --git a/src/background/repositories/BrowserSettingRepository.ts b/src/background/repositories/BrowserSettingRepository.ts index a47b64d..20013f4 100644 --- a/src/background/repositories/BrowserSettingRepository.ts +++ b/src/background/repositories/BrowserSettingRepository.ts @@ -1,18 +1,17 @@ -import { injectable } from 'tsyringe'; -import * as urls from '../../shared/urls'; +import { injectable } from "tsyringe"; +import * as urls from "../../shared/urls"; declare namespace browser.browserSettings.homepageOverride { - type BrowserSettings = { value: string; levelOfControl: LevelOfControlType; }; type LevelOfControlType = - 'not_controllable' | - 'controlled_by_other_extensions' | - 'controllable_by_this_extension' | - 'controlled_by_this_extension'; + | "not_controllable" + | "controlled_by_other_extensions" + | "controllable_by_this_extension" + | "controlled_by_this_extension"; function get(param: object): Promise<BrowserSettings>; } @@ -21,6 +20,6 @@ declare namespace browser.browserSettings.homepageOverride { export default class BrowserSettingRepository { async getHomepageUrls(): Promise<string[]> { const { value } = await browser.browserSettings.homepageOverride.get({}); - return value.split('|').map(urls.normalizeUrl); + return value.split("|").map(urls.normalizeUrl); } } diff --git a/src/background/repositories/CachedSettingRepository.ts b/src/background/repositories/CachedSettingRepository.ts index 1af15d4..e3d3950 100644 --- a/src/background/repositories/CachedSettingRepository.ts +++ b/src/background/repositories/CachedSettingRepository.ts @@ -1,17 +1,15 @@ -import MemoryStorage from '../infrastructures/MemoryStorage'; -import Settings from '../../shared/settings/Settings'; -import Properties from '../../shared/settings/Properties'; +import MemoryStorage from "../infrastructures/MemoryStorage"; +import Settings from "../../shared/settings/Settings"; +import Properties from "../../shared/settings/Properties"; -const CACHED_SETTING_KEY = 'setting'; +const CACHED_SETTING_KEY = "setting"; export default interface CachedSettingRepository { get(): Promise<Settings>; update(value: Settings): Promise<void>; - setProperty( - name: string, value: string | number | boolean, - ): Promise<void>; + setProperty(name: string, value: string | number | boolean): Promise<void>; } export class CachedSettingRepositoryImpl implements CachedSettingRepository { @@ -28,35 +26,36 @@ export class CachedSettingRepositoryImpl implements CachedSettingRepository { update(value: Settings): Promise<void> { this.cache.set(CACHED_SETTING_KEY, value.toJSON()); - return Promise.resolve() + return Promise.resolve(); } async setProperty( - name: string, value: string | number | boolean, + name: string, + value: string | number | boolean ): Promise<void> { const def = Properties.def(name); if (!def) { - throw new Error('unknown property: ' + name); + throw new Error("unknown property: " + name); } if (typeof value !== def.type) { throw new TypeError(`property type of ${name} mismatch: ${typeof value}`); } let newValue = value; - if (typeof value === 'string' && value === '') { + if (typeof value === "string" && value === "") { newValue = def.defaultValue; } const current = await this.get(); switch (name) { - case 'hintchars': - current.properties.hintchars = newValue as string; - break; - case 'smoothscroll': - current.properties.smoothscroll = newValue as boolean; - break; - case 'complete': - current.properties.complete = newValue as string; - break; + case "hintchars": + current.properties.hintchars = newValue as string; + break; + case "smoothscroll": + current.properties.smoothscroll = newValue as boolean; + break; + case "complete": + current.properties.complete = newValue as string; + break; } await this.update(current); } diff --git a/src/background/repositories/FindRepository.ts b/src/background/repositories/FindRepository.ts index 6a087f5..be56284 100644 --- a/src/background/repositories/FindRepository.ts +++ b/src/background/repositories/FindRepository.ts @@ -1,7 +1,7 @@ -import { injectable } from 'tsyringe'; -import MemoryStorage from '../infrastructures/MemoryStorage'; +import { injectable } from "tsyringe"; +import MemoryStorage from "../infrastructures/MemoryStorage"; -const FIND_KEYWORD_KEY = 'find-keyword'; +const FIND_KEYWORD_KEY = "find-keyword"; @injectable() export default class FindRepository { @@ -20,4 +20,3 @@ export default class FindRepository { return Promise.resolve(); } } - diff --git a/src/background/repositories/MarkRepository.ts b/src/background/repositories/MarkRepository.ts index 1f4ab0c..e2c1e94 100644 --- a/src/background/repositories/MarkRepository.ts +++ b/src/background/repositories/MarkRepository.ts @@ -1,8 +1,8 @@ -import { injectable } from 'tsyringe'; -import MemoryStorage from '../infrastructures/MemoryStorage'; -import GlobalMark from '../domains/GlobalMark'; +import { injectable } from "tsyringe"; +import MemoryStorage from "../infrastructures/MemoryStorage"; +import GlobalMark from "../domains/GlobalMark"; -const MARK_KEY = 'mark'; +const MARK_KEY = "mark"; @injectable() export default class MarkRepository { @@ -34,4 +34,3 @@ export default class MarkRepository { return this.cache.get(MARK_KEY) || {}; } } - diff --git a/src/background/repositories/RepeatRepository.ts b/src/background/repositories/RepeatRepository.ts index c7f7a71..e3ab43d 100644 --- a/src/background/repositories/RepeatRepository.ts +++ b/src/background/repositories/RepeatRepository.ts @@ -1,8 +1,8 @@ -import { injectable } from 'tsyringe'; -import { Operation } from '../../shared/operations'; -import MemoryStorage from '../infrastructures/MemoryStorage'; +import { injectable } from "tsyringe"; +import { Operation } from "../../shared/operations"; +import MemoryStorage from "../infrastructures/MemoryStorage"; -const REPEAT_KEY = 'repeat'; +const REPEAT_KEY = "repeat"; @injectable() export default class RepeatRepository { diff --git a/src/background/repositories/SettingRepository.ts b/src/background/repositories/SettingRepository.ts index b522045..d726cfb 100644 --- a/src/background/repositories/SettingRepository.ts +++ b/src/background/repositories/SettingRepository.ts @@ -1,4 +1,4 @@ -import SettingData from '../../shared/SettingData'; +import SettingData from "../../shared/SettingData"; export default interface SettingRepository { load(): Promise<SettingData | null>; @@ -8,7 +8,7 @@ export default interface SettingRepository { export class LocalSettingRepository implements SettingRepository { async load(): Promise<SettingData | null> { - const {settings} = await browser.storage.local.get('settings'); + const { settings } = await browser.storage.local.get("settings"); if (!settings) { return null; } @@ -17,7 +17,7 @@ export class LocalSettingRepository implements SettingRepository { onChange(callback: () => void) { browser.storage.onChanged.addListener((changes, area) => { - if (area !== 'local') { + if (area !== "local") { return; } if (changes.settings) { @@ -29,7 +29,7 @@ export class LocalSettingRepository implements SettingRepository { export class SyncSettingRepository implements SettingRepository { async load(): Promise<SettingData | null> { - const {settings} = await browser.storage.sync.get('settings'); + const { settings } = await browser.storage.sync.get("settings"); if (!settings) { return null; } @@ -38,7 +38,7 @@ export class SyncSettingRepository implements SettingRepository { onChange(callback: () => void) { browser.storage.onChanged.addListener((changes, area) => { - if (area !== 'sync') { + if (area !== "sync") { return; } if (changes.settings) { @@ -46,4 +46,4 @@ export class SyncSettingRepository implements SettingRepository { } }); } -}
\ No newline at end of file +} |