mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 11:38:51 -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))
|
||
|
}
|
||
|
}
|