diff --git a/src/background/presenters/Notifier.ts b/src/background/presenters/Notifier.ts index d586baf2..f7b035a2 100644 --- a/src/background/presenters/Notifier.ts +++ b/src/background/presenters/Notifier.ts @@ -1,12 +1,9 @@ import { injectable } from "inversify"; const NOTIFICATION_ID_UPDATE = "vimmatic-update"; -const NOTIFICATION_ID_INVALID_SETTINGS = "vimmatic-update-invalid-settings"; export default interface Notifier { notifyUpdated(version: string, onclick: () => void): Promise; - - notifyInvalidSettings(error: Error, onclick: () => void): Promise; } @injectable() @@ -31,29 +28,4 @@ export class NotifierImpl implements NotifierImpl { message, }); } - - async notifyInvalidSettings( - error: Error, - onclick: () => void - ): Promise { - const title = `Loading settings failed`; - // eslint-disable-next-line max-len - const message = `The default settings are used due to the last saved settings is invalid. Check your current settings from the add-on preference: ${error.message}`; - - const listener = (id: string) => { - if (id !== NOTIFICATION_ID_INVALID_SETTINGS) { - return; - } - onclick(); - chrome.notifications.onClicked.removeListener(listener); - }; - chrome.notifications.onClicked.addListener(listener); - - chrome.notifications.create(NOTIFICATION_ID_INVALID_SETTINGS, { - type: "basic", - iconUrl: chrome.extension.getURL("resources/icon_48x48.png"), - title, - message, - }); - } } diff --git a/src/background/presenters/ToolbarPresenter.ts b/src/background/presenters/ToolbarPresenter.ts index c8dcdd1b..debc4ff4 100644 --- a/src/background/presenters/ToolbarPresenter.ts +++ b/src/background/presenters/ToolbarPresenter.ts @@ -10,39 +10,13 @@ export default interface ToolbarPresenter { export class ToolbarPresenterImpl { async setEnabled(enabled: boolean): Promise { const path = enabled - ? "resources/enabled_32x32.png" - : "resources/disabled_32x32.png"; + ? "../resources/enabled_32x32.png" + : "../resources/disabled_32x32.png"; - // chrome.action is supported on v3 api - if ( - typeof chrome.action !== "undefined" && - typeof chrome.action.setIcon === "function" - ) { - return chrome.action.setIcon({ path }); - } - - // firefox does not support chrome.action - if ( - typeof chrome.browserAction !== "undefined" && - typeof chrome.browserAction.setIcon === "function" - ) { - // v2 api on chromium requires callback on the 2nd argument - return new Promise((resolve) => - chrome.browserAction.setIcon({ path }, resolve) - ); - } + return chrome.action.setIcon({ path }); } onClick(listener: (arg: chrome.tabs.Tab) => void): void { - // chrome.action is supported on v3 api - if (typeof chrome.action !== "undefined") { - chrome.action.onClicked.addListener(listener); - return; - } - - // firefox does not support chrome.action - if (typeof chrome.browserAction !== "undefined") { - chrome.action.onClicked.addListener(listener); - } + chrome.action.onClicked.addListener(listener); } }