Change client to not produce plugin keys manually
Summary: I **think** this is the last part of the codebase doing manipulation of strings to produce plugin keys etc. Reviewed By: passy Differential Revision: D18831990 fbshipit-source-id: db449d78230adbca66e78f041381a34d9b249a45
This commit is contained in:
committed by
Facebook Github Bot
parent
7f916f8a7b
commit
1a389202ca
@@ -23,6 +23,7 @@ import {registerPlugins} from './reducers/plugins';
|
|||||||
import createTableNativePlugin from './plugins/TableNativePlugin';
|
import createTableNativePlugin from './plugins/TableNativePlugin';
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
import invariant from 'invariant';
|
import invariant from 'invariant';
|
||||||
|
import {getPluginKey} from './utils/pluginUtils';
|
||||||
|
|
||||||
const MAX_BACKGROUND_TASK_TIME = 25;
|
const MAX_BACKGROUND_TASK_TIME = 25;
|
||||||
|
|
||||||
@@ -89,11 +90,7 @@ type Params = {
|
|||||||
};
|
};
|
||||||
type RequestMetadata = {method: string; id: number; params: Params | undefined};
|
type RequestMetadata = {method: string; id: number; params: Params | undefined};
|
||||||
|
|
||||||
const handleError = (
|
const handleError = (store: Store, device: BaseDevice, error: ErrorType) => {
|
||||||
store: Store,
|
|
||||||
deviceSerial: string | undefined,
|
|
||||||
error: ErrorType,
|
|
||||||
) => {
|
|
||||||
if (isProduction()) {
|
if (isProduction()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -104,7 +101,7 @@ const handleError = (
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pluginKey = `${deviceSerial || ''}#CrashReporter`;
|
const pluginKey = getPluginKey(null, device, 'CrashReporter');
|
||||||
|
|
||||||
const persistedState = {
|
const persistedState = {
|
||||||
...crashReporterPlugin.defaultPersistedState,
|
...crashReporterPlugin.defaultPersistedState,
|
||||||
@@ -366,9 +363,7 @@ export default class Client extends EventEmitter {
|
|||||||
}: ${error.message} + \nDevice Stack Trace: ${error.stacktrace}`,
|
}: ${error.message} + \nDevice Stack Trace: ${error.stacktrace}`,
|
||||||
'deviceError',
|
'deviceError',
|
||||||
);
|
);
|
||||||
this.deviceSerial().then(serial =>
|
this.device.then(device => handleError(this.store, device, error));
|
||||||
handleError(this.store, serial, error),
|
|
||||||
);
|
|
||||||
} else if (method === 'refreshPlugins') {
|
} else if (method === 'refreshPlugins') {
|
||||||
this.refreshPlugins();
|
this.refreshPlugins();
|
||||||
} else if (method === 'execute') {
|
} else if (method === 'execute') {
|
||||||
@@ -383,7 +378,7 @@ export default class Client extends EventEmitter {
|
|||||||
this.store.getState().plugins.clientPlugins.get(params.api) ||
|
this.store.getState().plugins.clientPlugins.get(params.api) ||
|
||||||
this.store.getState().plugins.devicePlugins.get(params.api);
|
this.store.getState().plugins.devicePlugins.get(params.api);
|
||||||
if (persistingPlugin && persistingPlugin.persistedStateReducer) {
|
if (persistingPlugin && persistingPlugin.persistedStateReducer) {
|
||||||
let pluginKey = `${this.id}#${params.api}`;
|
let pluginKey = getPluginKey(this.id, null, params.api);
|
||||||
if (persistingPlugin.prototype instanceof FlipperDevicePlugin) {
|
if (persistingPlugin.prototype instanceof FlipperDevicePlugin) {
|
||||||
// For device plugins, we are just using the device id instead of client id as the prefix.
|
// For device plugins, we are just using the device id instead of client id as the prefix.
|
||||||
this.deviceSerial().then(
|
this.deviceSerial().then(
|
||||||
@@ -450,9 +445,7 @@ export default class Client extends EventEmitter {
|
|||||||
reject(data.error);
|
reject(data.error);
|
||||||
const {error} = data;
|
const {error} = data;
|
||||||
if (error) {
|
if (error) {
|
||||||
this.deviceSerial().then(serial =>
|
this.device.then(device => handleError(this.store, device, error));
|
||||||
handleError(this.store, serial, error),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ???
|
// ???
|
||||||
|
|||||||
Reference in New Issue
Block a user