aboutsummaryrefslogtreecommitdiff
path: root/src/background/presenters
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/presenters')
-rw-r--r--src/background/presenters/HelpPresenter.ts4
-rw-r--r--src/background/presenters/IndicatorPresenter.ts9
-rw-r--r--src/background/presenters/Notifier.ts17
-rw-r--r--src/background/presenters/TabPresenter.ts35
-rw-r--r--src/background/presenters/WindowPresenter.ts2
5 files changed, 35 insertions, 32 deletions
diff --git a/src/background/presenters/HelpPresenter.ts b/src/background/presenters/HelpPresenter.ts
index f5c3a6b..7fa0597 100644
--- a/src/background/presenters/HelpPresenter.ts
+++ b/src/background/presenters/HelpPresenter.ts
@@ -1,6 +1,6 @@
-import { injectable } from 'tsyringe';
+import { injectable } from "tsyringe";
-const url = 'https://ueokande.github.io/vim-vixen/';
+const url = "https://ueokande.github.io/vim-vixen/";
@injectable()
export default class HelpPresenter {
diff --git a/src/background/presenters/IndicatorPresenter.ts b/src/background/presenters/IndicatorPresenter.ts
index 6a33e62..5b4b673 100644
--- a/src/background/presenters/IndicatorPresenter.ts
+++ b/src/background/presenters/IndicatorPresenter.ts
@@ -1,18 +1,17 @@
-import { injectable } from 'tsyringe';
+import { injectable } from "tsyringe";
@injectable()
export default class IndicatorPresenter {
indicate(enabled: boolean): Promise<void> {
const path = enabled
- ? 'resources/enabled_32x32.png'
- : 'resources/disabled_32x32.png';
- if (typeof browser.browserAction.setIcon === 'function') {
+ ? "resources/enabled_32x32.png"
+ : "resources/disabled_32x32.png";
+ if (typeof browser.browserAction.setIcon === "function") {
return browser.browserAction.setIcon({ path });
}
// setIcon not supported on Android
return Promise.resolve();
-
}
onClick(listener: (arg: browser.tabs.Tab) => void): void {
diff --git a/src/background/presenters/Notifier.ts b/src/background/presenters/Notifier.ts
index 57d58cb..2cd3225 100644
--- a/src/background/presenters/Notifier.ts
+++ b/src/background/presenters/Notifier.ts
@@ -1,5 +1,5 @@
-const NOTIFICATION_ID_UPDATE = 'vimvixen-update';
-const NOTIFICATION_ID_INVALID_SETTINGS = 'vimvixen-update-invalid-settings';
+const NOTIFICATION_ID_UPDATE = "vimvixen-update";
+const NOTIFICATION_ID_INVALID_SETTINGS = "vimvixen-update-invalid-settings";
export default interface Notifier {
notifyUpdated(version: string, onclick: () => void): Promise<void>;
@@ -10,7 +10,7 @@ export default interface Notifier {
export class NotifierImpl implements NotifierImpl {
async notifyUpdated(version: string, onclick: () => void): Promise<void> {
const title = `Vim Vixen ${version} has been installed`;
- const message = 'Click here to see release notes';
+ const message = "Click here to see release notes";
const listener = (id: string) => {
if (id !== NOTIFICATION_ID_UPDATE) {
@@ -22,8 +22,8 @@ export class NotifierImpl implements NotifierImpl {
browser.notifications.onClicked.addListener(listener);
await browser.notifications.create(NOTIFICATION_ID_UPDATE, {
- 'type': 'basic',
- 'iconUrl': browser.extension.getURL('resources/icon_48x48.png'),
+ type: "basic",
+ iconUrl: browser.extension.getURL("resources/icon_48x48.png"),
title,
message,
});
@@ -32,7 +32,8 @@ export class NotifierImpl implements NotifierImpl {
async notifyInvalidSettings(onclick: () => void): Promise<void> {
const title = `Loaded settings is invalid`;
// eslint-disable-next-line max-len
- const message = 'The default settings is used due to the last saved settings is invalid. Check your current settings from the add-on preference';
+ const message =
+ "The default settings is used due to the last saved settings is invalid. Check your current settings from the add-on preference";
const listener = (id: string) => {
if (id !== NOTIFICATION_ID_INVALID_SETTINGS) {
@@ -44,8 +45,8 @@ export class NotifierImpl implements NotifierImpl {
browser.notifications.onClicked.addListener(listener);
await browser.notifications.create(NOTIFICATION_ID_INVALID_SETTINGS, {
- 'type': 'basic',
- 'iconUrl': browser.extension.getURL('resources/icon_48x48.png'),
+ type: "basic",
+ iconUrl: browser.extension.getURL("resources/icon_48x48.png"),
title,
message,
});
diff --git a/src/background/presenters/TabPresenter.ts b/src/background/presenters/TabPresenter.ts
index bded5a2..09cfa23 100644
--- a/src/background/presenters/TabPresenter.ts
+++ b/src/background/presenters/TabPresenter.ts
@@ -1,7 +1,7 @@
-import MemoryStorage from '../infrastructures/MemoryStorage';
+import MemoryStorage from "../infrastructures/MemoryStorage";
-const CURRENT_SELECTED_KEY = 'tabs.current.selected';
-const LAST_SELECTED_KEY = 'tabs.last.selected';
+const CURRENT_SELECTED_KEY = "tabs.current.selected";
+const LAST_SELECTED_KEY = "tabs.last.selected";
type Tab = browser.tabs.Tab;
@@ -35,7 +35,7 @@ export default interface TabPresenter {
setZoom(tabId: number, factor: number): Promise<void>;
onSelected(
- listener: (arg: { tabId: number, windowId: number}) => void,
+ listener: (arg: { tabId: number; windowId: number }) => void
): void;
}
@@ -50,7 +50,8 @@ export class TabPresenterImpl implements TabPresenter {
async getCurrent(): Promise<Tab> {
const tabs = await browser.tabs.query({
- active: true, currentWindow: true
+ active: true,
+ currentWindow: true,
});
return tabs[0];
}
@@ -62,22 +63,24 @@ export class TabPresenterImpl implements TabPresenter {
async getLastSelectedId(): Promise<number | undefined> {
const cache = new MemoryStorage();
const tabId = await cache.get(LAST_SELECTED_KEY);
- if (tabId === null || typeof tabId === 'undefined') {
+ if (tabId === null || typeof tabId === "undefined") {
return;
}
return tabId;
}
- async getByKeyword(
- keyword: string, excludePinned = false,
- ): Promise<Tab[]> {
+ async getByKeyword(keyword: string, excludePinned = false): Promise<Tab[]> {
const tabs = await browser.tabs.query({ currentWindow: true });
- return tabs.filter((t) => {
- return t.url && t.url.toLowerCase().includes(keyword.toLowerCase()) ||
- t.title && t.title.toLowerCase().includes(keyword.toLowerCase());
- }).filter((t) => {
- return !(excludePinned && t.pinned);
- });
+ return tabs
+ .filter((t) => {
+ return (
+ (t.url && t.url.toLowerCase().includes(keyword.toLowerCase())) ||
+ (t.title && t.title.toLowerCase().includes(keyword.toLowerCase()))
+ );
+ })
+ .filter((t) => {
+ return !(excludePinned && t.pinned);
+ });
}
async select(tabId: number): Promise<void> {
@@ -125,7 +128,7 @@ export class TabPresenterImpl implements TabPresenter {
}
onSelected(
- listener: (arg: { tabId: number, windowId: number}) => void,
+ listener: (arg: { tabId: number; windowId: number }) => void
): void {
browser.tabs.onActivated.addListener(listener);
}
diff --git a/src/background/presenters/WindowPresenter.ts b/src/background/presenters/WindowPresenter.ts
index 150a48b..4f37f5d 100644
--- a/src/background/presenters/WindowPresenter.ts
+++ b/src/background/presenters/WindowPresenter.ts
@@ -1,4 +1,4 @@
-import { injectable } from 'tsyringe';
+import { injectable } from "tsyringe";
@injectable()
export default class WindowPresenter {