Browse Source

[RN] Fix processing outdated loadConfig requests

This fix is based on storing the location URL object we are loading the
configuration for in the redux store. Once the config has been loaded (or it has
failed, for that matter!) we'll check if the current "config URL" is the same we
set, and discard the old one if they don't match.
master
Saúl Ibarra Corretgé 7 years ago
parent
commit
357b206831
2 changed files with 14 additions and 3 deletions
  1. 12
    2
      react/features/app/actions.js
  2. 2
    1
      react/features/base/config/reducer.js

+ 12
- 2
react/features/app/actions.js View File

@@ -1,5 +1,7 @@
1 1
 /* @flow */
2 2
 
3
+import type { Dispatch } from 'redux';
4
+
3 5
 import { setRoom } from '../base/conference';
4 6
 import {
5 7
     configWillLoad,
@@ -71,9 +73,17 @@ function _appNavigateToMandatoryLocation(
71 73
      * @returns {void}
72 74
      */
73 75
     function loadConfigSettled(error, config) {
74
-        // FIXME Due to the asynchronous nature of the loading, the specified
76
+        // Due to the asynchronous nature of the loading, the specified
75 77
         // config may or may not be required by the time the notification
76
-        // arrives.
78
+        // arrives. If we receive the config for a location we are no longer
79
+        // interested in, just dump it.
80
+
81
+        const { locationURL: currentLocationURL }
82
+            = getState()['features/base/config'];
83
+
84
+        if (currentLocationURL !== newLocation) {
85
+            throw new Error('Config no longer needed');
86
+        }
77 87
 
78 88
         const promise
79 89
             = dispatch(setLocationURL(new URL(newLocation.toString())));

+ 2
- 1
react/features/base/config/reducer.js View File

@@ -53,7 +53,8 @@ ReducerRegistry.register(
53 53
         switch (action.type) {
54 54
         case CONFIG_WILL_LOAD:
55 55
             return {
56
-                error: undefined
56
+                error: undefined,
57
+                locationURL: action.locationURL
57 58
             };
58 59
 
59 60
         case LOAD_CONFIG_ERROR:

Loading…
Cancel
Save