feat: service worker cache static app resources, and all entry points (#18043)
* feat: service worker cache static app resources, and all entry points * review comments * review * lint * minor tweaks * review comments * optimize disabled cache --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { cancelLoad, getCachedOrFetch } from './cache';
|
||||
|
||||
export const installBroadcastChannelListener = () => {
|
||||
const broadcast = new BroadcastChannel('immich');
|
||||
// eslint-disable-next-line unicorn/prefer-add-event-listener
|
||||
broadcast.onmessage = (event) => {
|
||||
if (!event.data) {
|
||||
return;
|
||||
}
|
||||
const urlstring = event.data.url;
|
||||
const url = new URL(urlstring, event.origin);
|
||||
if (event.data.type === 'cancel') {
|
||||
cancelLoad(url.toString());
|
||||
} else if (event.data.type === 'preload') {
|
||||
getCachedOrFetch(url);
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user