Pass idler and statusupdate callback as an argument to the export persisted state function

Summary: This diff passes the idler and statusUpdate arguments to the export persisted state, as it is being used in the MobileConfig's export function

Reviewed By: passy

Differential Revision: D17715815

fbshipit-source-id: 98a0f0f5950254de2139c4aaa52cb73401c86c3c
This commit is contained in:
Pritesh Nandgaonkar
2019-10-04 05:28:36 -07:00
committed by Facebook Github Bot
parent 485898f5c7
commit 6e6873a4f6
2 changed files with 11 additions and 1 deletions

View File

@@ -101,6 +101,8 @@ export abstract class FlipperBasePlugin<
callClient: (method: string, params?: any) => Promise<any>, callClient: (method: string, params?: any) => Promise<any>,
persistedState: StaticPersistedState | undefined, persistedState: StaticPersistedState | undefined,
store: MiddlewareAPI | undefined, store: MiddlewareAPI | undefined,
idler?: Idler,
statusUpdate?: (msg: string) => void,
) => Promise<StaticPersistedState | undefined>) ) => Promise<StaticPersistedState | undefined>)
| null; | null;
static getActiveNotifications: static getActiveNotifications:

View File

@@ -381,6 +381,7 @@ export async function fetchMetadata(
pluginsMap: Map<string, typeof FlipperDevicePlugin | typeof FlipperPlugin>, pluginsMap: Map<string, typeof FlipperDevicePlugin | typeof FlipperPlugin>,
store: MiddlewareAPI, store: MiddlewareAPI,
statusUpdate?: (msg: string) => void, statusUpdate?: (msg: string) => void,
idler?: Idler,
): Promise<{pluginStates: PluginStatesState; errorArray: Array<Error>}> { ): Promise<{pluginStates: PluginStatesState; errorArray: Array<Error>}> {
const newPluginState = {...pluginStates}; const newPluginState = {...pluginStates};
const errorArray: Array<Error> = []; const errorArray: Array<Error> = [];
@@ -413,7 +414,13 @@ export async function fetchMetadata(
statusUpdate(`Fetching metadata for plugin ${plugin}...`); statusUpdate(`Fetching metadata for plugin ${plugin}...`);
const data = await promiseTimeout( const data = await promiseTimeout(
120000, // Timeout in 2 mins 120000, // Timeout in 2 mins
exportState(callClient(client, plugin), newPluginState[key], store), exportState(
callClient(client, plugin),
newPluginState[key],
store,
idler,
statusUpdate,
),
`Timed out while collecting data for ${plugin}`, `Timed out while collecting data for ${plugin}`,
); );
newPluginState[key] = data; newPluginState[key] = data;
@@ -459,6 +466,7 @@ export async function getStoreExport(
pluginsMap, pluginsMap,
store, store,
statusUpdate, statusUpdate,
idler,
); );
const {errorArray} = metadata; const {errorArray} = metadata;
const newPluginState = metadata.pluginStates; const newPluginState = metadata.pluginStates;