chiyadev / genshin-schedule

🕑 Genshin farming scheduler
https://genshin.chiya.dev
MIT License
72 stars 17 forks source link

Register Service Worker to make the website installable as PWA #61

Closed ysc3839 closed 3 years ago

ysc3839 commented 3 years ago

And don't force landscape orientation in manifest.

luaneko commented 3 years ago

I'm not sure if Genshin Schedule would benefit from service workers, because it's generally expected to be open alongside the game which requires an internet connection.

I also think this will completely break the website for users who enabled synchronization, because the website heavily relies on fetching the latest synchronized data and sending patches when you change things. This doesn't work without an internet connection.

ysc3839 commented 3 years ago

The service worker does nothing. It won't break the website. For example, a Chinese forum v2ex.com use the same way to make it installable: https://v2ex.com/sw.js

var CACHE_NAME = 'v2ex-cache-v1';
var urlsToCache = [
    '/static/fonts/PressStart2P-Regular.ttf'
];

self.addEventListener('install', function(event) {
    // Perform install steps
    event.waitUntil(
        caches.open(CACHE_NAME).then(cache => cache.addAll(urlsToCache))
    );
});

self.addEventListener('fetch', () => {});
luaneko commented 3 years ago

The service worker does nothing. It won't break the website.

Interesting. I have little knowledge on what service workers do or how they are implemented, so this is good to know.