Improve device destruction code [8/n]
Summary: Some cleanup in device destruction code. This diff wraps up the stack that decouples device management from the UI. Next steps are client management, and system management (file access / command execution) Reviewed By: passy Differential Revision: D31084036 fbshipit-source-id: 93efee7dba2193589d3c08c51128ce03de5eff7f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
dce92b16db
commit
987755bb09
@@ -76,6 +76,21 @@ export default async (store: Store, logger: Logger) => {
|
||||
serial: deviceInfo.serial,
|
||||
});
|
||||
|
||||
const existing = store
|
||||
.getState()
|
||||
.connections.devices.find(
|
||||
(device) => device.serial === deviceInfo.serial,
|
||||
);
|
||||
// handled outside reducer, as it might emit new redux actions...
|
||||
if (existing) {
|
||||
if (existing.connected.get()) {
|
||||
console.warn(
|
||||
`Tried to replace still connected device '${existing.serial}' with a new instance.`,
|
||||
);
|
||||
}
|
||||
existing.destroy();
|
||||
}
|
||||
|
||||
const device = new BaseDevice(server, deviceInfo);
|
||||
device.loadDevicePlugins(
|
||||
store.getState().plugins.devicePlugins,
|
||||
|
||||
Reference in New Issue
Block a user