aboutsummaryrefslogtreecommitdiff
path: root/src/background/presenters/NotifyPresenter.ts
blob: a81f2274190b613b9e5aed6c319623dbbcd07be5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const NOTIFICATION_ID = 'vimvixen-update';

export default class NotifyPresenter {
  notify(title, message, onclick) {
    const listener = (id) => {
      if (id !== NOTIFICATION_ID) {
        return;
      }

      onclick();

      browser.notifications.onClicked.removeListener(listener);
    };
    browser.notifications.onClicked.addListener(listener);

    return browser.notifications.create(NOTIFICATION_ID, {
      'type': 'basic',
      'iconUrl': browser.extension.getURL('resources/icon_48x48.png'),
      title,
      message,
    });
  }
}