Skip to content

Instantly share code, notes, and snippets.

Federico Zivolo FezVrasta

Block or report user

Report or block FezVrasta

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View apocalypseHandler.js
window.addEventListener('error', async err => {
// Since we are handling the error here, we must make
// sure we log it into the console nonetheless, otherwise
// it will be very difficult to understand why your app
// is crashing.
console.error(err);
// If no service worker is available, our work ends here
// because we don't need to unregister the service worker
// to make sure the user is able to get a newer version of
View useServiceWorker.js
serviceWorker.register({
onUpdate: registration => {
setWaitingServiceWorker(registration.waiting);
setUpdateAvailable(true);
},
onWaiting: waiting => {
setWaitingServiceWorker(waiting);
setUpdateAvailable(true);
}
});
View serviceWorker.js
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
// WE ADD THE CODE BELOW
if (registration.waiting) {
if (config && config.onWaiting) {
config.onWaiting(registration.waiting);
}
}
View serviceWorker.js
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
// WE ADD THE CODE BELOW
if (registration.waiting) {
if (config && config.onWaiting) {
config.onWaiting(registration.waiting);
}
}
View index.js
import { ServiceWorkerProvider, useServiceWorker } from './useServiceWorker';
const App = () => {
const { isUpdateAvailable, updateAssets } = useServiceWorker();
return (
<div>
Hello, World!
{isUpdateAvailable && (
View serviceWorker.js
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
View useServiceWorker.js
const ServiceWorkerContext = React.createContext();
export const ServiceWorkerProvider = ({ children }) => {
const [waitingServiceWorker, setWaitingServiceWorker] = useState(null);
const [isUpdateAvailable, setUpdateAvailable] = useState(false);
React.useEffect(() => {
serviceWorker.register({
onUpdate: registration => {
setWaitingServiceWorker(registration.waiting);
View index.js
const [waitingServiceWorker, setWaitingServiceWorker] = useState(null);
const [isUpdateAvailable, setUpdateAvailable] = useState(false);
React.useEffect(() => {
serviceWorker.register({
onUpdate: registration => {
setWaitingServiceWorker(registration.waiting);
setUpdateAvailable(true);
}
});
@FezVrasta
FezVrasta / privacy-policy.md
Created Sep 18, 2018
Notifications for GitHub privacy policy
View privacy-policy.md

Notifications for GitHub privacy policy

Notifications for GitHub (the application) doesn't directly collect or share any user information without the explicit consent of the user.

To use the application, the user is required to login with their own GitHub, Inc. account,
the authentication process is directly handled by GitHub and no informations are collected by the application.

In order to use the notifications system, the user is required to login to (or create an account with) ZEIT, Inc's Now.sh service.
The authentication is directly handled by ZEIT and no informations are collected by the application.
A GitHub token will be stored in the user's ZEIT Now.sh account in order to collect the notifications and send them to the push notification system of

View spectrum-chat.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.