Skip to content

Commit

Permalink
Rewrite the service worker, #11
Browse files Browse the repository at this point in the history
  • Loading branch information
Elhamne committed Feb 25, 2023
1 parent e1806c1 commit 6c4be2f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 130 deletions.
126 changes: 0 additions & 126 deletions public/serviceworker.js

This file was deleted.

58 changes: 58 additions & 0 deletions public/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* eslint-disable array-callback-return */
/* eslint-disable no-undef */
// const staticCacheName = 'SAY-v2.0.0-beta';
// const urlsToCache = [
// '/static/js/main.chunk.js',
// '/static/js/0.chunk.js',
// '/static/js/bundle.js',
// '/static/js/vendors~main.chunk.js',
// '/static/js/main.482930e5.chunk.js',
// '/static/js/2.a637ec1e.chunk.js',
// '/images/back_gray.svg',
// '/images/back_orange.svg',
// '/images/logo.png',
// '/images/back.svg',
// '/images/icons/changePassword.svg',
// '/images/icons/email.svg',
// '/images/icons/exit.svg',
// '/images/icons/info.svg',
// '/images/icons/language.svg',
// '/images/icons/Money.svg',
// '/images/icons/settings.svg',
// '/images/icons/Task.svg',
// '/images/icons/un.svg',
// '/images/icons/upload.svg',
// '/images/icons/wallet.svg',
// '/images/icons/family.svg',
// '/images/icons/doneNeeds/child.svg',
// '/images/icons/doneNeeds/hand.svg',
// '/images/icons/doneNeeds/ngo.svg',
// '/images/icons/doneNeeds/package.svg',
// '/images/icons/doneNeeds/receipts/done.jpg',
// '/images/icons/doneNeeds/receipts/ngo_delivered.jpg',
// '/images/icons/doneNeeds/receipts/done.jpg',
// '/images/cartWhite.svg',
// '/images/favicon.png',
// '/images/finalForm.svg',
// '/images/say_donation.svg',
// '/images/back.svg',
// '/images/intro.png',
// '/images/otp.svg',
// '/images/register.svg',
// '/offline.html',
// ];

// Install service worker
self.addEventListener('install', (e) => {
console.log('service worker installed');
});

// activate event
self.addEventListener('activate', (e) => {
console.log('service worker has been activated');
});

// fetch event
self.addEventListener('fetch', (e) => {
console.log('fetch event', e);
});
6 changes: 2 additions & 4 deletions src/swDev.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/* eslint-disable no-undef */
export default function swDev() {
console.log('initiating service worker...');
const swUrl = `${process.env.PUBLIC_URL}/serviceworker.js`;
console.log(`swurl = ${swUrl}`);
const swUrl = `${process.env.PUBLIC_URL}/sw.js`;

if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register(swUrl)
.then((reg) => console.log('success: ', reg.scope))
.then((reg) => console.log('success: ', reg))
.catch((err) => console.log('Failiure: ', err));
}
}

0 comments on commit 6c4be2f

Please sign in to comment.