Bug: cannot export data / submit bug without selected device / client
Summary: Without selected device or client, it is currently impossible to submit a bug report. This diff fixes that. Reviewed By: jknoxville Differential Revision: D19251701 fbshipit-source-id: fd0dc0c779fb27d93ed02a404da76a7e6b251b94
This commit is contained in:
committed by
Facebook Github Bot
parent
9acf23596e
commit
5d25b77622
@@ -469,23 +469,14 @@ async function processQueues(
|
|||||||
|
|
||||||
function getSelection(
|
function getSelection(
|
||||||
store: MiddlewareAPI,
|
store: MiddlewareAPI,
|
||||||
): {client: Client; device: BaseDevice} {
|
): {client: Client | null; device: BaseDevice | null} {
|
||||||
const state = store.getState();
|
const state = store.getState();
|
||||||
const {clients} = state.connections;
|
const {clients} = state.connections;
|
||||||
const client = clients.find(
|
const client = clients.find(
|
||||||
client => client.id === state.connections.selectedApp,
|
client => client.id === state.connections.selectedApp,
|
||||||
);
|
);
|
||||||
const {selectedDevice} = state.connections;
|
const {selectedDevice} = state.connections;
|
||||||
// TODO: T59434642 remove these restrictions
|
return {client: client ?? null, device: selectedDevice};
|
||||||
if (!selectedDevice) {
|
|
||||||
throw new Error('Please select a device before exporting data.');
|
|
||||||
}
|
|
||||||
// TODO: T39612653 Make Client mockable. Currently rsocket logic is tightly coupled.
|
|
||||||
// Not passing the entire state as currently Client is not mockable.
|
|
||||||
if (!client) {
|
|
||||||
throw new Error('Please select a client before exporting data.');
|
|
||||||
}
|
|
||||||
return {client, device: selectedDevice};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function determinePluginsToProcess(
|
export function determinePluginsToProcess(
|
||||||
@@ -498,10 +489,11 @@ export function determinePluginsToProcess(
|
|||||||
|
|
||||||
const pluginsToProcess: PluginsToProcess = [];
|
const pluginsToProcess: PluginsToProcess = [];
|
||||||
const selectedPlugins = state.plugins.selectedPlugins;
|
const selectedPlugins = state.plugins.selectedPlugins;
|
||||||
const selectedFilteredPlugins =
|
const selectedFilteredPlugins = client
|
||||||
selectedPlugins.length > 0
|
? selectedPlugins.length > 0
|
||||||
? client.plugins.filter(plugin => selectedPlugins.includes(plugin))
|
? client.plugins.filter(plugin => selectedPlugins.includes(plugin))
|
||||||
: client.plugins;
|
: client.plugins
|
||||||
|
: [];
|
||||||
for (const client of clients) {
|
for (const client of clients) {
|
||||||
if (!device || device.isArchived || !client.id.includes(device.serial)) {
|
if (!device || device.isArchived || !client.id.includes(device.serial)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -560,7 +552,7 @@ export async function getStoreExport(
|
|||||||
activeNotifications,
|
activeNotifications,
|
||||||
device,
|
device,
|
||||||
pluginStates: newPluginState,
|
pluginStates: newPluginState,
|
||||||
clients: [client.toJSON()],
|
clients: client ? [client.toJSON()] : [],
|
||||||
devicePlugins,
|
devicePlugins,
|
||||||
clientPlugins,
|
clientPlugins,
|
||||||
salt: uuid.v4(),
|
salt: uuid.v4(),
|
||||||
@@ -609,8 +601,7 @@ export async function exportStore(
|
|||||||
);
|
);
|
||||||
return {serializedString, errorArray};
|
return {serializedString, errorArray};
|
||||||
} else {
|
} else {
|
||||||
console.error('Make sure a device is connected');
|
return {serializedString: '{}', errorArray: []};
|
||||||
throw new Error('No device is selected');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user