diff options
Diffstat (limited to 'src/background/presenters/NotifyPresenter.ts')
-rw-r--r-- | src/background/presenters/NotifyPresenter.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/background/presenters/NotifyPresenter.ts b/src/background/presenters/NotifyPresenter.ts new file mode 100644 index 0000000..23932f7 --- /dev/null +++ b/src/background/presenters/NotifyPresenter.ts @@ -0,0 +1,27 @@ +const NOTIFICATION_ID = 'vimvixen-update'; + +export default class NotifyPresenter { + async notify( + title: string, + message: string, + onclick: () => void, + ): Promise<void> { + const listener = (id: string) => { + if (id !== NOTIFICATION_ID) { + return; + } + + onclick(); + + browser.notifications.onClicked.removeListener(listener); + }; + browser.notifications.onClicked.addListener(listener); + + await browser.notifications.create(NOTIFICATION_ID, { + 'type': 'basic', + 'iconUrl': browser.extension.getURL('resources/icon_48x48.png'), + title, + message, + }); + } +} |