fix(pwa) move logic for registering pwa worker

This commit is contained in:
Tudor-Ovidiu Avram 2020-10-16 15:16:21 +03:00 committed by Saúl Ibarra Corretgé
parent d854b2cd3d
commit e67c08d837
3 changed files with 15 additions and 9 deletions

View File

@ -13,3 +13,4 @@ lang /usr/share/jitsi-meet/
connection_optimization /usr/share/jitsi-meet/ connection_optimization /usr/share/jitsi-meet/
resources/robots.txt /usr/share/jitsi-meet/ resources/robots.txt /usr/share/jitsi-meet/
resources/*.sh /usr/share/jitsi-meet/scripts/ resources/*.sh /usr/share/jitsi-meet/scripts/
pwa-worker.js /usr/share/jitsi-meet/

View File

@ -10,7 +10,6 @@
<link rel="apple-touch-icon" href="images/apple-touch-icon.png"> <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
<link rel="stylesheet" href="css/all.css"> <link rel="stylesheet" href="css/all.css">
<link rel="manifest" href="static/pwa/manifest.json"> <link rel="manifest" href="static/pwa/manifest.json">
<script> <script>
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
if (!JitsiMeetJS.app) { if (!JitsiMeetJS.app) {
@ -20,6 +19,20 @@
JitsiMeetJS.app.renderEntryPoint({ JitsiMeetJS.app.renderEntryPoint({
Component: JitsiMeetJS.app.entryPoints.APP Component: JitsiMeetJS.app.entryPoints.APP
}) })
const isElectron = navigator.userAgent.includes('Electron');
const shouldRegisterWorker = !isElectron && 'serviceWorker' in navigator;
if (shouldRegisterWorker) {
navigator.serviceWorker
.register('pwa-worker.js')
.then(reg => {
console.log('Service worker registered.', reg);
})
.catch(err => {
console.log(err);
});
}
}) })
</script> </script>
<script> <script>

View File

@ -6,11 +6,9 @@ import ReactDOM from 'react-dom';
import { getJitsiMeetTransport } from '../modules/transport'; import { getJitsiMeetTransport } from '../modules/transport';
import { App } from './features/app/components'; import { App } from './features/app/components';
import { browser } from './features/base/lib-jitsi-meet';
import { getLogger } from './features/base/logging/functions'; import { getLogger } from './features/base/logging/functions';
import { Platform } from './features/base/react'; import { Platform } from './features/base/react';
import { getJitsiMeetGlobalNS } from './features/base/util'; import { getJitsiMeetGlobalNS } from './features/base/util';
import { loadScript } from './features/base/util/loadScript';
import PrejoinApp from './features/prejoin/components/PrejoinApp'; import PrejoinApp from './features/prejoin/components/PrejoinApp';
const logger = getLogger('index.web'); const logger = getLogger('index.web');
@ -24,12 +22,6 @@ document.addEventListener('DOMContentLoaded', () => {
APP.connectionTimes['document.ready'] = now; APP.connectionTimes['document.ready'] = now;
logger.log('(TIME) document ready:\t', now); logger.log('(TIME) document ready:\t', now);
if (!browser.isElectron()) {
const base = window.location.origin;
loadScript(`${base}/static/pwa/registrator.js`);
}
}); });
// Workaround for the issue when returning to a page with the back button and // Workaround for the issue when returning to a page with the back button and