Process queues before exporting plugins

Summary: This diff makes sure that pending queues for plugins that are selected are processed before making a flipper export.

Reviewed By: jknoxville

Differential Revision: D19194211

fbshipit-source-id: e076375889450407e7f94384051719f3bbc415ee
This commit is contained in:
Michel Weststrate
2020-01-02 07:12:06 -08:00
committed by Facebook Github Bot
parent 0494a84d98
commit b8e752412e
8 changed files with 222 additions and 131 deletions

View File

@@ -8,7 +8,7 @@
*/
import {PersistedStateReducer} from '../plugin';
import {Store, State} from '../reducers/index';
import {State, MiddlewareAPI} from '../reducers/index';
import {setPluginState} from '../reducers/pluginStates';
import {flipperRecorderAddEvent} from './pluginStateRecorder';
import {
@@ -92,7 +92,7 @@ function processMessage(
}
export function processMessageImmediately(
store: Store,
store: MiddlewareAPI,
pluginKey: string,
plugin: {
defaultPersistedState: any;
@@ -122,7 +122,7 @@ export function processMessageImmediately(
}
export function processMessageLater(
store: Store,
store: MiddlewareAPI,
pluginKey: string,
plugin: {
defaultPersistedState: any;
@@ -168,7 +168,7 @@ export async function processMessageQueue(
persistedStateReducer: PersistedStateReducer | null;
},
pluginKey: string,
store: Store,
store: MiddlewareAPI,
progressCallback?: (progress: {current: number; total: number}) => void,
idler: BaseIdler = new Idler(),
) {
@@ -226,6 +226,9 @@ export async function processMessageQueue(
} while (getPendingMessages(store, pluginKey).length);
}
function getPendingMessages(store: Store, pluginKey: string): Message[] {
function getPendingMessages(
store: MiddlewareAPI,
pluginKey: string,
): Message[] {
return store.getState().pluginMessageQueue[pluginKey] || [];
}