瀏覽代碼

fix(pwa) move logic for registering pwa worker

master
Tudor-Ovidiu Avram 4 年之前
父節點
當前提交
e67c08d837
共有 3 個檔案被更改,包括 15 行新增9 行删除
  1. 1
    0
      debian/jitsi-meet-web.install
  2. 14
    1
      index.html
  3. 0
    8
      react/index.web.js

+ 1
- 0
debian/jitsi-meet-web.install 查看文件

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

+ 14
- 1
index.html 查看文件

@@ -10,7 +10,6 @@
10 10
     <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
11 11
     <link rel="stylesheet" href="css/all.css">
12 12
     <link rel="manifest" href="static/pwa/manifest.json">
13
-
14 13
     <script>
15 14
         document.addEventListener('DOMContentLoaded', () => {
16 15
             if (!JitsiMeetJS.app) {
@@ -20,6 +19,20 @@
20 19
             JitsiMeetJS.app.renderEntryPoint({
21 20
                 Component: JitsiMeetJS.app.entryPoints.APP
22 21
             })
22
+
23
+            const isElectron = navigator.userAgent.includes('Electron');
24
+            const shouldRegisterWorker = !isElectron && 'serviceWorker' in navigator;
25
+
26
+            if (shouldRegisterWorker) {
27
+                navigator.serviceWorker
28
+                    .register('pwa-worker.js')
29
+                    .then(reg => {
30
+                        console.log('Service worker registered.', reg);
31
+                    })
32
+                    .catch(err => {
33
+                        console.log(err);
34
+                    });
35
+            }
23 36
         })
24 37
     </script>
25 38
     <script>

+ 0
- 8
react/index.web.js 查看文件

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

Loading…
取消
儲存