Procházet zdrojové kódy

feat: implement PageReloadOverlay

master
paweldomas před 9 roky
rodič
revize
2a5b4dde31
4 změnil soubory, kde provedl 111 přidání a 20 odebrání
  1. 1
    1
      conference.js
  2. 2
    1
      lang/main.json
  3. 3
    18
      modules/UI/UI.js
  4. 105
    0
      modules/UI/reload_overlay/PageReloadOverlay.js

+ 1
- 1
conference.js Zobrazit soubor

@@ -380,7 +380,7 @@ class ConferenceConnector {
380 380
             // the app. Both the errors above are unrecoverable from the library
381 381
             // perspective.
382 382
             room.leave().then(() => connection.disconnect());
383
-            APP.UI.notifyVideoConferencingNotAvailable();
383
+            APP.UI.showPageReloadOverlay();
384 384
             break;
385 385
 
386 386
         case ConferenceErrors.CONFERENCE_MAX_USERS:

+ 2
- 1
lang/main.json Zobrazit soubor

@@ -202,7 +202,8 @@
202 202
         "detectext": "Error when trying to detect desktopsharing extension.",
203 203
         "failtoinstall": "Failed to install desktop sharing extension",
204 204
         "failedpermissions": "Failed to obtain permissions to use the local microphone and/or camera.",
205
-        "serviceUnavailableMsg": "The video conferencing service is currently unavailable. Please try again later!",
205
+        "conferenceReloadMsg": "Something went wrong we'll try to reload the conference in...",
206
+        "conferenceReloadTimeLeft": "__seconds__ sec.",
206 207
         "maxUsersLimitReached": "The limit for maximum number of participants in the conference has been reached. The conference is full. Please try again later!",
207 208
         "lockTitle": "Lock failed",
208 209
         "lockMessage": "Failed to lock the conference.",

+ 3
- 18
modules/UI/UI.js Zobrazit soubor

@@ -14,12 +14,12 @@ import Recording from "./recording/Recording";
14 14
 import GumPermissionsOverlay
15 15
     from './gum_overlay/UserMediaPermissionsGuidanceOverlay';
16 16
 
17
+import PageReloadOverlay from './reload_overlay/PageReloadOverlay';
17 18
 import VideoLayout from "./videolayout/VideoLayout";
18 19
 import FilmStrip from "./videolayout/FilmStrip";
19 20
 import SettingsMenu from "./side_pannels/settings/SettingsMenu";
20 21
 import Profile from "./side_pannels/profile/Profile";
21 22
 import Settings from "./../settings/Settings";
22
-import { reload } from '../util/helpers';
23 23
 import RingOverlay from "./ring_overlay/RingOverlay";
24 24
 import UIErrors from './UIErrors';
25 25
 
@@ -1110,23 +1110,8 @@ UI.notifyFocusDisconnected = function (focus, retrySec) {
1110 1110
  * Notify the user that the video conferencing service is badly broken and
1111 1111
  * the page should be reloaded.
1112 1112
  */
1113
-UI.notifyVideoConferencingNotAvailable = function () {
1114
-    let title = APP.translation.generateTranslationHTML(
1115
-        'dialog.serviceUnavailable'
1116
-    );
1117
-    let msg = APP.translation.generateTranslationHTML(
1118
-        'dialog.serviceUnavailableMsg'
1119
-    );
1120
-    messageHandler.openDialog(
1121
-        title,
1122
-        msg,
1123
-        true, // persistent
1124
-        [{title: 'retry'}],
1125
-        function () {
1126
-            reload();
1127
-            return false;
1128
-        }
1129
-    );
1113
+UI.showPageReloadOverlay = function () {
1114
+    PageReloadOverlay.show(15 /* will reload in 15 seconds */);
1130 1115
 };
1131 1116
 
1132 1117
 /**

+ 105
- 0
modules/UI/reload_overlay/PageReloadOverlay.js Zobrazit soubor

@@ -0,0 +1,105 @@
1
+/* global $, APP, AJS */
2
+
3
+import { reload } from '../../util/helpers';
4
+
5
+let $overlay;
6
+
7
+/**
8
+ * Conference reload counter in seconds.
9
+ * @type {number}
10
+ */
11
+let timeLeft;
12
+
13
+/**
14
+ * Conference reload timeout in seconds.
15
+ * @type {number}
16
+ */
17
+let timeout;
18
+
19
+/**
20
+ * Internal function that constructs overlay with the warning message and count
21
+ * down towards the conference reload.
22
+ */
23
+function buildReloadOverlayHtml() {
24
+    $overlay = $(`
25
+        <div class='overlay_container'>
26
+            <div class='overlay_content'>
27
+                <span data-i18n='dialog.serviceUnavailable' 
28
+                      class='overlay_text_small'></span>
29
+                <span data-i18n='dialog.conferenceReloadMsg' 
30
+                      class='overlay_text_small'></span>
31
+                <div>
32
+                    <div id='reloadProgressBar' class="aui-progress-indicator">
33
+                        <span class="aui-progress-indicator-value"></span>
34
+                    </div>
35
+                    <span id='reloadSecRemaining' class='overlay_text_small'>
36
+                    </span>
37
+                </div>
38
+            </div>
39
+        </div>`);
40
+
41
+    APP.translation.translateElement($overlay);
42
+}
43
+
44
+/**
45
+ * Updates the progress indicator position and the label with the time left.
46
+ */
47
+function updateDisplay() {
48
+
49
+    const timeLeftTxt
50
+        = APP.translation.translateString(
51
+            "dialog.conferenceReloadTimeLeft",
52
+            { seconds: timeLeft });
53
+    $("#reloadSecRemaining").text(timeLeftTxt);
54
+
55
+    const ratio = (timeout-timeLeft)/timeout;
56
+    AJS.progressBars.update("#reloadProgressBar", ratio);
57
+}
58
+
59
+/**
60
+ * Starts the reload countdown with the animation.
61
+ * @param {number} timeoutSeconds how many seconds before the conference
62
+ * reload will happen.
63
+ */
64
+function start(timeoutSeconds) {
65
+
66
+    timeLeft = timeout = timeoutSeconds;
67
+
68
+    // Initialize displays
69
+    updateDisplay();
70
+
71
+    var intervalId = window.setInterval(function() {
72
+
73
+        if (timeLeft >= 1) {
74
+            timeLeft -= 1;
75
+            console.info("Reloading in " + timeLeft + " seconds...");
76
+        }
77
+
78
+        updateDisplay();
79
+
80
+        if (timeLeft === 0) {
81
+            console.info("Reloading!");
82
+            window.clearInterval(intervalId);
83
+            reload();
84
+        }
85
+    }, 1000);
86
+}
87
+
88
+export default {
89
+    /**
90
+     * Shows the page reload overlay which will do the conference reload after
91
+     * the given amount of time.
92
+     *
93
+     * @param {number} timeoutSeconds how many seconds before the conference
94
+     * reload will happen.
95
+     */
96
+    show(timeoutSeconds) {
97
+
98
+        !$overlay && buildReloadOverlayHtml();
99
+
100
+        if (!$overlay.parents('body').length) {
101
+            $overlay.appendTo('body');
102
+            start(timeoutSeconds);
103
+        }
104
+    }
105
+};

Načítá se…
Zrušit
Uložit