Back out "[flipper] disconnect client instead of removing it"

Summary:
Original commit changeset: 650ef1344b8b

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: D16280931

fbshipit-source-id: 48e09b876e631aa87372054e706cdb9a2b3e2eb7
This commit is contained in:
John Knox
2019-07-16 08:30:43 -07:00
committed by Facebook Github Bot
parent a097e673d8
commit 782c23393a

View File

@@ -11,7 +11,6 @@ import type {Store} from '../reducers/index.js';
import type {Logger} from '../fb-interfaces/Logger.js';
import type Client from '../Client.js';
import type {UninitializedClient} from '../UninitializedClient';
import type BaseDevice from '../devices/BaseDevice';
export default (store: Store, logger: Logger) => {
const server = new Server(logger, store);
@@ -32,31 +31,6 @@ export default (store: Store, logger: Logger) => {
});
server.addListener('removed-client', (id: string) => {
const client: ?Client = store
.getState()
.connections.clients.find((client: Client) => client.id === id);
if (client) {
const device: ?BaseDevice = store
.getState()
.connections.devices.find(
(device: BaseDevice) => device.serial === client.query.device_id,
);
if (device && !device.isArchived && device.os === 'Android') {
client.connected = false;
client.connection = null;
// find all plugins for this client that store data in persistedState
client.plugins = Object.keys(store.getState().pluginStates)
.filter(key => key.startsWith(id))
.map(key => key.split('#').pop());
// don't remove client if it still has plugins
if (client.plugins.length > 0) {
return;
}
}
}
store.dispatch({
type: 'CLIENT_REMOVED',
payload: id,