[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.
This commit is contained in:
Saúl Ibarra Corretgé 2018-05-23 12:48:59 +02:00 committed by Lyubo Marinov
parent d557a6505d
commit 357b206831
2 changed files with 14 additions and 3 deletions

View File

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

View File

@ -53,7 +53,8 @@ ReducerRegistry.register(
switch (action.type) {
case CONFIG_WILL_LOAD:
return {
error: undefined
error: undefined,
locationURL: action.locationURL
};
case LOAD_CONFIG_ERROR: