diff --git a/preload.js b/preload.js index 17267c1..ce7ef2f 100644 --- a/preload.js +++ b/preload.js @@ -95,7 +95,7 @@ window.init = function init() { }; document.getElementById('add-device-button').onchange = function addDeviceClick(e) { - DEVICE.registerDevice( + const newDevice = DEVICE.registerDevice( { type: e.target.value, defaultName: 'New Device', @@ -106,6 +106,7 @@ window.init = function init() { ); e.target.selectedIndex = 0; + VIEW.switchDevice(newDevice.id); SAVESLOTS.saveAll(); }; diff --git a/src/device.js b/src/device.js index ee23047..6fe846b 100644 --- a/src/device.js +++ b/src/device.js @@ -70,7 +70,7 @@ function registerDevice(newDevice, discoveryMethod) { VIEW.addDeviceToList(devices[id]); initDeviceConnection(id); - return true; + return devices[id]; } module.exports.registerDevice = registerDevice;