forked from Ivasoft/mattermost-mobile
* 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:
committed by
Miguel Alatzar
parent
62758221d4
commit
7378e116d6
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user