Fixed broken navigation plugin
Summary: The navigation plugin threw exceptions, as the defaultPersisted state was not mixed into the already stored state, making some fields unreadable Reviewed By: jknoxville Differential Revision: D19554291 fbshipit-source-id: 57f045aa1eae10682e44d479b9aecb51f0391b9e
This commit is contained in:
committed by
Facebook Github Bot
parent
23625f7a89
commit
e9ff9addc6
@@ -143,10 +143,7 @@ export function processMessageImmediately(
|
||||
},
|
||||
message: {method: string; params?: any},
|
||||
) {
|
||||
const persistedState: any =
|
||||
store.getState().pluginStates[pluginKey] ??
|
||||
plugin.defaultPersistedState ??
|
||||
{};
|
||||
const persistedState = getCurrentPluginState(store, plugin, pluginKey);
|
||||
const newPluginState = processMessage(
|
||||
persistedState,
|
||||
pluginKey,
|
||||
@@ -217,10 +214,7 @@ export async function processMessageQueue(
|
||||
break;
|
||||
}
|
||||
// there are messages to process! lets do so until we have to idle
|
||||
const persistedState =
|
||||
store.getState().pluginStates[pluginKey] ??
|
||||
plugin.defaultPersistedState ??
|
||||
{};
|
||||
const persistedState = getCurrentPluginState(store, plugin, pluginKey);
|
||||
let offset = 0;
|
||||
let newPluginState = persistedState;
|
||||
do {
|
||||
@@ -267,3 +261,15 @@ function getPendingMessages(
|
||||
): Message[] {
|
||||
return store.getState().pluginMessageQueue[pluginKey] || [];
|
||||
}
|
||||
|
||||
function getCurrentPluginState(
|
||||
store: MiddlewareAPI,
|
||||
plugin: {defaultPersistedState: any},
|
||||
pluginKey: string,
|
||||
) {
|
||||
// possible optimization: don't spread default state here by put proper default state when initializing clients
|
||||
return {
|
||||
...plugin.defaultPersistedState,
|
||||
...store.getState().pluginStates[pluginKey],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user