Skip to content

Commit

Permalink
Changes based on code review
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Apr 29, 2024
1 parent a345468 commit 45530dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion web/src/client/network/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const DeviceState = Object.freeze({
UNAVAILABLE: "unavailable",
DISCONNECTED: "disconnected",
CONFIG: "config",
NEEDAUTH: "auth",
NEEDAUTH: "needAuth",
ACTIVATED: "activated",
DEACTIVATING: "deactivating",
FAILED: "failed"
Expand Down
17 changes: 10 additions & 7 deletions web/src/components/overview/NetworkSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,22 @@ export default function NetworkSection() {
switch (type) {
case NetworkEventTypes.DEVICE_ADDED: {
setDevices((devs) => {
const newDevices = devs.filter((d) => d.name !== payload.name);
if (payload.connection) return newDevices;
const currentDevices = devs.filter((d) => d.name !== payload.name);
// only show connecting or connected devices
if (!payload.connection) return currentDevices;

return [...newDevices, client.fromApiDevice(payload)];
return [...currentDevices, client.fromApiDevice(payload)];
});
break;
}

case NetworkEventTypes.DEVICE_UPDATED: {
const [name, data] = payload;
setDevices(devs => {
const newDevices = devs.filter((d) => d.name !== name);
return [...newDevices, client.fromApiDevice(data)];
const currentDevices = devs.filter((d) => d.name !== name);
// only show connecting or connected devices
if (!data.connection) return currentDevices;
return [...currentDevices, client.fromApiDevice(data)];
});
break;
}
Expand Down Expand Up @@ -95,8 +98,8 @@ export default function NetworkSection() {
const summary = activeDevices.map(deviceSummary);

const msg = sprintf(
// TRANSLATORS: header for the list of active network connections,
// %d is replaced by the number of active connections
// TRANSLATORS: header for the list of connected devices,
// %d is replaced by the number of active devices
n_("%d device set:", "%d devices set:", total), total
);

Expand Down

0 comments on commit 45530dc

Please sign in to comment.