Преглед на файлове

fix(base/connection/reducer): clear 'connection' field

Currently the listeners for disconnected and failed connection events
are unsubscribed as soon as the connection is established, so
the CONNECTION_DISCONNECTED is never triggered which would clear the
'connection' field. This commit will clear the 'connection' state on
CONNECTION_WILL_CONNECT. It's needed anyway given that there's no
guarantee on when and if the async disconnect operation will finish.

One issue caused by the 'connection' not cleared was that
CONNECTION_FAILED was not reduced correctly and the reload screen was
not displayed for the following scenario:
1. Join and leave any working conference.
2. Turn off network connectivity on the device.
3. Wait for CONNECTION_FAILED. The reload screen will not be displayed,
   because CONNECTION_FAILED is not reduced correctly, because the old
   'connection' value is still there.
master
paweldomas преди 7 години
родител
ревизия
022954b40b
променени са 1 файла, в които са добавени 22 реда и са изтрити 6 реда
  1. 22
    6
      react/features/base/connection/reducer.js

+ 22
- 6
react/features/base/connection/reducer.js Целия файл

@@ -57,7 +57,9 @@ ReducerRegistry.register(
57 57
 function _connectionDisconnected(
58 58
         state: Object,
59 59
         { connection }: { connection: Object }) {
60
-    if (state.connection !== connection) {
60
+    const connection_ = _getCurrentConnection(state);
61
+
62
+    if (connection_ !== connection) {
61 63
         return state;
62 64
     }
63 65
 
@@ -104,11 +106,7 @@ function _connectionFailed(
104 106
             connection: Object,
105 107
             error: ConnectionFailedError
106 108
         }) {
107
-
108
-    // The current (similar to getCurrentConference in
109
-    // base/conference/functions.js) connection which is connecting or
110
-    // connected:
111
-    const connection_ = state.connection || state.connecting;
109
+    const connection_ = _getCurrentConnection(state);
112 110
 
113 111
     if (connection_ && connection_ !== connection) {
114 112
         return state;
@@ -139,6 +137,11 @@ function _connectionWillConnect(
139 137
         { connection }: { connection: Object }) {
140 138
     return assign(state, {
141 139
         connecting: connection,
140
+
141
+        // We don't care if the previous connection has been closed already,
142
+        // because it's an async process and there's no guarantee if it'll be
143
+        // done before the new one is established.
144
+        connection: undefined,
142 145
         error: undefined,
143 146
         passwordRequired: undefined
144 147
     });
@@ -188,6 +191,19 @@ function _constructOptions(locationURL: URL) {
188 191
     };
189 192
 }
190 193
 
194
+/**
195
+ * The current (similar to getCurrentConference in base/conference/functions.js)
196
+ * connection which is {@code connection} or {@code connecting}.
197
+ *
198
+ * @param {Object} baseConnectionState - The current state of the
199
+ * {@code 'base/connection'} feature.
200
+ * @returns {JitsiConnection} - The current {@code JitsiConnection} if any.
201
+ * @private
202
+ */
203
+function _getCurrentConnection(baseConnectionState: Object): ?Object {
204
+    return baseConnectionState.connection || baseConnectionState.connecting;
205
+}
206
+
191 207
 /**
192 208
  * Reduces a specific redux action {@link SET_LOCATION_URL} of the feature
193 209
  * base/connection.

Loading…
Отказ
Запис