Call exportPersistedState only for clients of a selected device
Summary:
Call `exportPersistedState` only for the clients of selectedDevice. This will fasten up our export, we do not need to call `exportPersistedState` for the clients of nonSelectedDevice.
{F159322777}
Reviewed By: passy
Differential Revision: D15440652
fbshipit-source-id: e018603cfeb56fec462b54a6897fb254cc361390
This commit is contained in:
committed by
Facebook Github Bot
parent
0a514c3618
commit
2c024a4488
@@ -191,6 +191,10 @@ export async function getStoreExport(
|
|||||||
const {clients} = state.connections;
|
const {clients} = state.connections;
|
||||||
const {pluginStates} = state;
|
const {pluginStates} = state;
|
||||||
const {plugins} = state;
|
const {plugins} = state;
|
||||||
|
const {selectedDevice} = store.getState().connections;
|
||||||
|
if (!selectedDevice) {
|
||||||
|
throw new Error('Please select a device before exporting data.');
|
||||||
|
}
|
||||||
const newPluginState = {...pluginStates};
|
const newPluginState = {...pluginStates};
|
||||||
// TODO: T39612653 Make Client mockable. Currently rsocket logic is tightly coupled.
|
// TODO: T39612653 Make Client mockable. Currently rsocket logic is tightly coupled.
|
||||||
// Not passing the entire state as currently Client is not mockable.
|
// Not passing the entire state as currently Client is not mockable.
|
||||||
@@ -207,6 +211,9 @@ export async function getStoreExport(
|
|||||||
});
|
});
|
||||||
const errorArray: Array<Error> = [];
|
const errorArray: Array<Error> = [];
|
||||||
for (let client of clients) {
|
for (let client of clients) {
|
||||||
|
if (!client.id.includes(selectedDevice.serial)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (let plugin of client.plugins) {
|
for (let plugin of client.plugins) {
|
||||||
const pluginClass: ?Class<
|
const pluginClass: ?Class<
|
||||||
FlipperDevicePlugin<> | FlipperPlugin<>,
|
FlipperDevicePlugin<> | FlipperPlugin<>,
|
||||||
@@ -230,7 +237,6 @@ export async function getStoreExport(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const {activeNotifications} = store.getState().notifications;
|
const {activeNotifications} = store.getState().notifications;
|
||||||
const {selectedDevice} = store.getState().connections;
|
|
||||||
const {devicePlugins} = store.getState().plugins;
|
const {devicePlugins} = store.getState().plugins;
|
||||||
|
|
||||||
const exportData = await processStore(
|
const exportData = await processStore(
|
||||||
@@ -249,16 +255,20 @@ export function exportStore(
|
|||||||
): Promise<{serializedString: string, errorArray: Array<Error>}> {
|
): Promise<{serializedString: string, errorArray: Array<Error>}> {
|
||||||
getLogger().track('usage', EXPORT_FLIPPER_TRACE_EVENT);
|
getLogger().track('usage', EXPORT_FLIPPER_TRACE_EVENT);
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const {exportData, errorArray} = await getStoreExport(store);
|
try {
|
||||||
if (!exportData) {
|
const {exportData, errorArray} = await getStoreExport(store);
|
||||||
console.error('Make sure a device is connected');
|
if (!exportData) {
|
||||||
reject('No device is selected');
|
console.error('Make sure a device is connected');
|
||||||
|
reject('No device is selected');
|
||||||
|
}
|
||||||
|
const serializedString = serialize(exportData);
|
||||||
|
if (serializedString.length <= 0) {
|
||||||
|
reject('Serialize function returned empty string');
|
||||||
|
}
|
||||||
|
resolve({serializedString, errorArray});
|
||||||
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
}
|
}
|
||||||
const serializedString = serialize(exportData);
|
|
||||||
if (serializedString.length <= 0) {
|
|
||||||
reject('Serialize function returned empty string');
|
|
||||||
}
|
|
||||||
resolve({serializedString, errorArray});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user