diff options
Diffstat (limited to 'src/background/infrastructures')
-rw-r--r-- | src/background/infrastructures/ContentMessageClient.ts | 6 | ||||
-rw-r--r-- | src/background/infrastructures/ContentMessageListener.ts | 17 | ||||
-rw-r--r-- | src/background/infrastructures/MemoryStorage.ts | 4 |
3 files changed, 14 insertions, 13 deletions
diff --git a/src/background/infrastructures/ContentMessageClient.ts b/src/background/infrastructures/ContentMessageClient.ts index 4d2284c..b6c0c23 100644 --- a/src/background/infrastructures/ContentMessageClient.ts +++ b/src/background/infrastructures/ContentMessageClient.ts @@ -4,8 +4,8 @@ import * as messages from '../../shared/messages'; @injectable() export default class ContentMessageClient { async broadcastSettingsChanged(): Promise<void> { - let tabs = await browser.tabs.query({}); - for (let tab of tabs) { + const tabs = await browser.tabs.query({}); + for (const tab of tabs) { if (!tab.id || tab.url && tab.url.startsWith('about:')) { continue; } @@ -16,7 +16,7 @@ export default class ContentMessageClient { } async getAddonEnabled(tabId: number): Promise<boolean> { - let enabled = await browser.tabs.sendMessage(tabId, { + const enabled = await browser.tabs.sendMessage(tabId, { type: messages.ADDON_ENABLED_QUERY, }); return enabled as any as boolean; diff --git a/src/background/infrastructures/ContentMessageListener.ts b/src/background/infrastructures/ContentMessageListener.ts index f80d686..d063810 100644 --- a/src/background/infrastructures/ContentMessageListener.ts +++ b/src/background/infrastructures/ContentMessageListener.ts @@ -1,5 +1,6 @@ import { injectable } from 'tsyringe'; import * as messages from '../../shared/messages'; +import * as operations from '../../shared/operations'; import CompletionGroup from '../domains/CompletionGroup'; import CommandController from '../controllers/CommandController'; import SettingController from '../controllers/SettingController'; @@ -19,7 +20,7 @@ export default class ContentMessageListener { private findController: FindController, private addonEnabledController: AddonEnabledController, private linkController: LinkController, - private backgroundOperationController: OperationController, + private operationController: OperationController, private markController: MarkController, ) { this.consolePorts = {}; @@ -30,7 +31,7 @@ export default class ContentMessageListener { message: any, sender: browser.runtime.MessageSender, ) => { try { - let ret = this.onMessage(message, sender.tab as browser.tabs.Tab); + const ret = this.onMessage(message, sender.tab as browser.tabs.Tab); if (!(ret instanceof Promise)) { return {}; } @@ -79,7 +80,7 @@ export default class ContentMessageListener { senderTab.id as number, message.background); case messages.BACKGROUND_OPERATION: - return this.onBackgroundOperation(message.operation); + return this.onBackgroundOperation(message.repeat, message.operation); case messages.MARK_SET_GLOBAL: return this.onMarkSetGlobal(message.key, message.x, message.y); case messages.MARK_JUMP_GLOBAL: @@ -93,7 +94,7 @@ export default class ContentMessageListener { } async onConsoleQueryCompletions(line: string): Promise<CompletionGroup[]> { - let completions = await this.commandController.getCompletions(line); + const completions = await this.commandController.getCompletions(line); return Promise.resolve(completions); } @@ -126,8 +127,8 @@ export default class ContentMessageListener { return this.linkController.openToTab(url, openerId); } - onBackgroundOperation(operation: any): Promise<any> { - return this.backgroundOperationController.exec(operation); + onBackgroundOperation(count: number, op: operations.Operation): Promise<any> { + return this.operationController.exec(count, op); } onMarkSetGlobal(key: string, x: number, y: number): Promise<any> { @@ -139,7 +140,7 @@ export default class ContentMessageListener { } onConsoleFrameMessage(tabId: number, message: any): void { - let port = this.consolePorts[tabId]; + const port = this.consolePorts[tabId]; if (!port) { return; } @@ -152,7 +153,7 @@ export default class ContentMessageListener { } if (port.sender && port.sender.tab && port.sender.tab.id) { - let id = port.sender.tab.id; + const id = port.sender.tab.id; this.consolePorts[id] = port; } } diff --git a/src/background/infrastructures/MemoryStorage.ts b/src/background/infrastructures/MemoryStorage.ts index baf9ffa..af445a6 100644 --- a/src/background/infrastructures/MemoryStorage.ts +++ b/src/background/infrastructures/MemoryStorage.ts @@ -2,7 +2,7 @@ const db: {[key: string]: any} = {}; export default class MemoryStorage { set(name: string, value: any): void { - let data = JSON.stringify(value); + const data = JSON.stringify(value); if (typeof data === 'undefined') { throw new Error('value is not serializable'); } @@ -10,7 +10,7 @@ export default class MemoryStorage { } get(name: string): any { - let data = db[name]; + const data = db[name]; if (!data) { return undefined; } |