<commit_before>export function CustomListeners () {
  return (worker) => new CustomListenersImpl(worker)
}

export class CustomListenersImpl {

  setup (ops) {}

  constructor () {}

}<commit_msg>Add notifications on incoming call<commit_after>export function CustomListeners () {
  return (worker) => new CustomListenersImpl(worker);
}

export class CustomListenersImpl {

  setup (ops) {}

  constructor (worker) {
    self.addEventListener('push', function (event) {
        var payload = event.data.json().notification;

        if ( payload.data.action === 'call-incoming' ) {
          event.waitUntil(
            self.registration.showNotification('Webph.one - Incoming call', {
              body: payload.data.from,
              vibrate: [200, 100, 200, 100, 200, 100, 400],
              tag: 'request',
              icon: 'assets/icons/android-chrome-192x192.png',
              actions: [
                { action: 'yes', title: 'Answer' },
                { action: 'no', title: 'Hang up' }
              ]
            })
          )
        }
    });

    self.addEventListener('notificationclick', function (event) {
      event.notification.close()

      if (event.action == 'yes') {
        event.waitUntil(
          clients.openWindow('/#/call').then(function (windowClient) {
          })
        )
      }
    })

    self.addEventListener('notificationclose', function (event) {
    })
  }

}
{'fraction_non_alphanumeric': 0.13469675599435826, 'fraction_numerical': 0.01904090267983075, 'mean_word_length': 2.2031602708803613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1682989', 'n_tokens_mistral': 418, 'n_tokens_neox': 386, 'n_words': 81}