Automated cherry pick of #3677 (#3679)

* MM-21085 Updated waitHydration

Updated the hydration of hte store to first check if it completed as this was being caused due to a race condition.

* MM-21085 Updated for callback

MM-21085 Updated for callback
This commit is contained in:
Mattermost Build
2019-12-09 20:58:09 +01:00
committed by Miguel Alatzar
parent 62758221d4
commit 7378e116d6

View File

@@ -42,14 +42,20 @@ export function transformSet(incoming, setTransforms, toStorage = true) {
}
export function waitForHydration(store, callback) {
const subscription = () => {
if (store.getState().views.root.hydrationComplete) {
unsubscribeFromStore();
if (callback && typeof callback === 'function') {
callback();
}
if (store.getState().views.root.hydrationComplete) {
if (callback && typeof callback === 'function') {
callback();
}
};
} else {
const subscription = () => {
if (store.getState().views.root.hydrationComplete) {
unsubscribeFromStore();
if (callback && typeof callback === 'function') {
callback();
}
}
};
const unsubscribeFromStore = store.subscribe(subscription);
const unsubscribeFromStore = store.subscribe(subscription);
}
}