Back out "[flipper] fix reconnecting clients"
Summary: Original commit changeset: 1d0e6ce17c89 Backing this out until we can come up with a better way to do it. The change was introduced so that when a device disconnects / crashes, we don't lose all plugin state, and you can still see what was on screen before the crash.. However, there are some problems with this solution, which get quite complicated. Putting them here for future reference: * Closing an app results in the plugins staying there, and there's no way to tell it's not actually connected. * If the app reconnects, the JS plugin doesn't get re-initialized. Even though the client plugin has been. Reviewed By: bnelo12 Differential Revision: D16280932 fbshipit-source-id: 92585cdd0dace2012924df4106327a1e21ab9f9b
This commit is contained in:
committed by
Facebook Github Bot
parent
42c887e634
commit
a097e673d8
@@ -10,7 +10,6 @@ import child_process from 'child_process';
|
||||
import type {Store} from '../reducers/index.js';
|
||||
import type BaseDevice from '../devices/BaseDevice';
|
||||
import type {Logger} from '../fb-interfaces/Logger.js';
|
||||
import type Client from '../Client.js';
|
||||
import {registerDeviceCallbackOnPlugins} from '../utils/onRegisterDevice.js';
|
||||
import {getAdbClient} from '../utils/adbClient';
|
||||
import {default as which} from 'which';
|
||||
@@ -161,7 +160,7 @@ export default (store: Store, logger: Logger) => {
|
||||
});
|
||||
|
||||
// remove offline devices with same serial as the connected.
|
||||
const reconnectedDevices: Array<string> = store
|
||||
const reconnectedDevices = store
|
||||
.getState()
|
||||
.connections.devices.filter(
|
||||
(device: BaseDevice) =>
|
||||
@@ -169,32 +168,10 @@ export default (store: Store, logger: Logger) => {
|
||||
)
|
||||
.map(device => device.serial);
|
||||
|
||||
if (reconnectedDevices.length > 0) {
|
||||
reconnectedDevices.forEach((device: string) => {
|
||||
// remove all disconnected clients for the reconnected device
|
||||
store
|
||||
.getState()
|
||||
.connections.clients.filter(
|
||||
(client: Client) => client.query.device_id === device,
|
||||
)
|
||||
.forEach((client: Client) => {
|
||||
store.dispatch({
|
||||
type: 'CLIENT_REMOVED',
|
||||
payload: client.id,
|
||||
});
|
||||
store.dispatch({
|
||||
type: 'CLEAR_CLIENT_PLUGINS',
|
||||
payload: client.id,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// remove archived devices of previously connected devices
|
||||
store.dispatch({
|
||||
type: 'UNREGISTER_DEVICES',
|
||||
payload: new Set(reconnectedDevices),
|
||||
});
|
||||
}
|
||||
store.dispatch({
|
||||
type: 'UNREGISTER_DEVICES',
|
||||
payload: new Set(reconnectedDevices),
|
||||
});
|
||||
|
||||
store.dispatch({
|
||||
type: 'REGISTER_DEVICE',
|
||||
|
||||
@@ -237,9 +237,7 @@ const reducer = (state: State = INITAL_STATE, action: Action): State => {
|
||||
|
||||
return {
|
||||
...state,
|
||||
clients: state.clients
|
||||
.filter((client: Client) => client.id !== payload.id)
|
||||
.concat(payload),
|
||||
clients: state.clients.concat(payload),
|
||||
uninitializedClients: state.uninitializedClients.filter(c => {
|
||||
return (
|
||||
c.deviceId !== payload.query.device_id ||
|
||||
|
||||
@@ -24,10 +24,6 @@ export type Action =
|
||||
| {
|
||||
type: 'CLEAR_PLUGIN_STATE',
|
||||
payload: {id: string, devicePlugins: Set<string>},
|
||||
}
|
||||
| {
|
||||
type: 'CLEAR_CLIENT_PLUGINS',
|
||||
payload: string,
|
||||
};
|
||||
|
||||
const INITIAL_STATE: State = {};
|
||||
@@ -59,14 +55,6 @@ export default function reducer(
|
||||
}
|
||||
return newState;
|
||||
}, {});
|
||||
} else if (action.type === 'CLEAR_CLIENT_PLUGINS') {
|
||||
const {payload} = action;
|
||||
return Object.keys(state).reduce((newState, pluginKey) => {
|
||||
if (!pluginKey.startsWith(payload)) {
|
||||
newState[pluginKey] = state[pluginKey];
|
||||
}
|
||||
return newState;
|
||||
}, {});
|
||||
} else {
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user