mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
20 lines
470 B
JavaScript
20 lines
470 B
JavaScript
|
let pendingWorkerSetup = Promise.resolve()
|
||
|
|
||
|
function supportsServiceWorker() {
|
||
|
return 'serviceWorker' in navigator
|
||
|
}
|
||
|
|
||
|
export function waitForServiceWorker() {
|
||
|
return pendingWorkerSetup
|
||
|
}
|
||
|
|
||
|
export function loadServiceWorker() {
|
||
|
if (supportsServiceWorker()) {
|
||
|
pendingWorkerSetup = navigator.serviceWorker
|
||
|
.register('/serviceWorker.js', {
|
||
|
scope: '/project/',
|
||
|
})
|
||
|
.catch(error => console.warn('Cannot register serviceWorker', error))
|
||
|
}
|
||
|
}
|