<commit_before>/* eslint-env worker */
/* global toolbox, clients */

importScripts('/sw-toolbox.js');
import * as localforage from 'localforage';

console.log(localforage);

// Try network but fallback to cache
toolbox.router.default = toolbox.networkFirst;

// Data should query the network first
toolbox.router.any('/api/*', toolbox.networkOnly);

// Data should query the network first
toolbox.router.any('/auth/*', toolbox.networkOnly);

self.addEventListener('push', function(event) {
	if (!(self.Notification && self.Notification.permission === 'granted')) {
		return;
	}

	let data = {};
	if (event.data) {
		data = event.data.json();
	}
	const title = data.title || 'Something Has Happened';
	const message = data.message || 'Here\'s something you might want to check out.';
	const icon = data.icon || 'launcher-icon-4x.png';

	const notification = new Notification(title, {
		body: message,
		tag: 'simple-push-demo-notification',
		icon: icon
	});

	notification.addEventListener('click', function() {
		if (clients.openWindow) {
			clients.openWindow('https://81.ada.is/');
		}
	});
});<commit_msg>notifications<commit_after>/* eslint-env worker */
/* global toolbox, clients */

importScripts('/sw-toolbox.js');
import * as localforage from 'localforage';

console.log(localforage);

// Try network but fallback to cache
toolbox.router.default = toolbox.networkFirst;

// Data should query the network first
toolbox.router.any('/api/*', toolbox.networkOnly);

// Data should query the network first
toolbox.router.any('/auth/*', toolbox.networkOnly);

self.addEventListener('push', function(event) {
	if (!(self.Notification && self.Notification.permission === 'granted')) {
		return;
	}

	if (!('showNotification' in ServiceWorkerRegistration.prototype)) {
		console.warn('Notifications aren\'t supported.');
		return;
    }

	let data = {};
	if (event.data) {
		data = event.data.json();
	}
	const title = data.title || 'Something Has Happened';
	const message = data.message || 'Here\'s something you might want to check out.';
	const icon = data.icon || 'launcher-icon-4x.png';

	event.waitUntil(self.registration.showNotification(title, {
		body: message,
		icon: icon
	}).then(function ({notification}) {
		notification.addEventListener('click', function() {
			if (clients.openWindow) {
				clients.openWindow('https://81.ada.is/');
			}
		});
	}));
});
{'fraction_non_alphanumeric': 0.16266329540665825, 'fraction_numerical': 0.0025284450063211127, 'mean_word_length': 4.346846846846847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5790347', 'n_tokens_mistral': 768, 'n_tokens_neox': 730, 'n_words': 177}