Sort uninitialized devices in redux state
Summary: Stops them from jumping around if they try to connect more than once. Reviewed By: passy Differential Revision: D13084056 fbshipit-source-id: 803538298c45b9c28e5116f072518e8632b0f1cf
This commit is contained in:
committed by
Facebook Github Bot
parent
093ab1fe57
commit
7821b6b5a9
@@ -269,31 +269,36 @@ export default function reducer(
|
||||
...state,
|
||||
uninitializedClients: state.uninitializedClients
|
||||
.filter(entry => !isEqual(entry.client, payload))
|
||||
.concat([{client: payload}]),
|
||||
.concat([{client: payload}])
|
||||
.sort((a, b) => a.client.appName.localeCompare(b.client.appName)),
|
||||
};
|
||||
}
|
||||
case 'FINISH_CLIENT_SETUP': {
|
||||
const {payload} = action;
|
||||
return {
|
||||
...state,
|
||||
uninitializedClients: state.uninitializedClients.map(
|
||||
c =>
|
||||
isEqual(c.client, payload.client)
|
||||
? {...c, deviceId: payload.deviceId}
|
||||
: c,
|
||||
),
|
||||
uninitializedClients: state.uninitializedClients
|
||||
.map(
|
||||
c =>
|
||||
isEqual(c.client, payload.client)
|
||||
? {...c, deviceId: payload.deviceId}
|
||||
: c,
|
||||
)
|
||||
.sort((a, b) => a.client.appName.localeCompare(b.client.appName)),
|
||||
};
|
||||
}
|
||||
case 'CLIENT_SETUP_ERROR': {
|
||||
const {payload} = action;
|
||||
return {
|
||||
...state,
|
||||
uninitializedClients: state.uninitializedClients.map(
|
||||
c =>
|
||||
isEqual(c.client, payload.client)
|
||||
? {...c, error: payload.error.message}
|
||||
: c,
|
||||
),
|
||||
uninitializedClients: state.uninitializedClients
|
||||
.map(
|
||||
c =>
|
||||
isEqual(c.client, payload.client)
|
||||
? {...c, error: payload.error.message}
|
||||
: c,
|
||||
)
|
||||
.sort((a, b) => a.client.appName.localeCompare(b.client.appName)),
|
||||
};
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user