fix reconnecting clients
Summary: When an archived device reconnected, the clients from the architved device weren't removed and a new client was added. This caused a client to be shown multiple times after reconnecting a device. In this diff, all clients and pluginStates from an archived device are removed once the device reconnects. Reviewed By: passy Differential Revision: D16075349 fbshipit-source-id: 1d0e6ce17c89bb75dd993466bca6bd64e2c63338
This commit is contained in:
committed by
Facebook Github Bot
parent
28d4e6409d
commit
f2c8fe0205
@@ -237,7 +237,9 @@ const reducer = (state: State = INITAL_STATE, action: Action): State => {
|
||||
|
||||
return {
|
||||
...state,
|
||||
clients: state.clients.concat(payload),
|
||||
clients: state.clients
|
||||
.filter((client: Client) => client.id !== payload.id)
|
||||
.concat(payload),
|
||||
uninitializedClients: state.uninitializedClients.filter(c => {
|
||||
return (
|
||||
c.deviceId !== payload.query.device_id ||
|
||||
|
||||
@@ -24,6 +24,10 @@ export type Action =
|
||||
| {
|
||||
type: 'CLEAR_PLUGIN_STATE',
|
||||
payload: {id: string, devicePlugins: Set<string>},
|
||||
}
|
||||
| {
|
||||
type: 'CLEAR_CLIENT_PLUGINS',
|
||||
payload: string,
|
||||
};
|
||||
|
||||
const INITIAL_STATE: State = {};
|
||||
@@ -55,6 +59,14 @@ 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