Просмотр исходного кода

fix(web_ios): Not rendering when the browser back button is pressed.

j8
hristoterezov 7 лет назад
Родитель
Сommit
6aae56527f
1 измененных файлов: 19 добавлений и 0 удалений
  1. 19
    0
      react/index.web.js

+ 19
- 0
react/index.web.js Просмотреть файл

@@ -6,8 +6,10 @@ import ReactDOM from 'react-dom';
6 6
 import { getJitsiMeetTransport } from '../modules/transport';
7 7
 
8 8
 import { App } from './features/app';
9
+import { Platform } from './features/base/react';
9 10
 
10 11
 const logger = require('jitsi-meet-logger').getLogger(__filename);
12
+const OS = Platform.OS;
11 13
 
12 14
 /**
13 15
  * Renders the app when the DOM tree has been loaded.
@@ -22,6 +24,23 @@ document.addEventListener('DOMContentLoaded', () => {
22 24
     ReactDOM.render(<App />, document.getElementById('react'));
23 25
 });
24 26
 
27
+// Workaround for the issue when returning to a page with the back button and
28
+// the page is loaded from the 'back-forward' cache on iOS which causes nothing
29
+// to be rendered.
30
+if (OS === 'ios') {
31
+    window.addEventListener('pageshow', event => {
32
+        // Detect pages loaded from the 'back-forward' cache
33
+        // (https://webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/)
34
+        if (event.persisted) {
35
+            // Maybe there is a more graceful approach but in the moment of
36
+            // writing nothing else resolves the issue. I tried to execute our
37
+            // DOMContentLoaded handler but it seems that the 'onpageshow' event
38
+            // is triggered only when 'window.location.reload()' code exists.
39
+            window.location.reload();
40
+        }
41
+    });
42
+}
43
+
25 44
 /**
26 45
  * Stops collecting the logs and disposing the API when the user closes the
27 46
  * page.

Загрузка…
Отмена
Сохранить