Skip to content

Commit

Permalink
fix: fix service worker ready error
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanyxh committed May 15, 2024
1 parent a996e65 commit 583aedb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
22 changes: 11 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions src/viewer/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ function ServiceWorkerCache() {
const handleSwitchServiceWorkerCache = async (
enableServiceWorkerCache: boolean
) => {
setSpinning(true);
/*
TIPS: When we turn off the Service Worker, Ready will never be resolved because the page is not related to the service worker
*/
// const registration = await window.navigator.serviceWorker.ready;

const registration = await window.navigator.serviceWorker.ready;
// if (registration.waiting || registration.installing) {
// return error(
// 'service worker 正在安装中,此过程不可被打断,请稍后执行此操作。'
// );
// }

if (registration.waiting || registration.installing) {
return error(
'service worker 正在安装中,此过程不可被打断,请稍后执行此操作。'
);
}
setSpinning(true);

if (enableServiceWorkerCache) {
return serviceWorkerRef.current
Expand Down
1 change: 1 addition & 0 deletions src/viewer/styles/Index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
img {
width: 100%;
height: 100%;
user-select: none;
}
}
}
Expand Down

0 comments on commit 583aedb

Please sign in to comment.