mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
feat v1.29.0: 'new device' flag with a red dot
- auto devices/light groups appearing after install get a server-side 'new' flag (settings.new_device_ids) and a red dot top-right of the icon; opening the device's editor clears it for every client - known_devices baseline seeded silently on first run — upgrades never flood the plan with dots; hand-made markers never flagged - pure diffNewDevices + unit tests; backend schema; smoke_new_device.mjs; TESTING.md row
This commit is contained in:
@@ -732,3 +732,20 @@ export function parseRoomRef(
|
||||
}
|
||||
return { space, area: rest, roomId: null };
|
||||
}
|
||||
|
||||
// ---------------- new-device detection ----------------
|
||||
|
||||
/**
|
||||
* Which auto-appearing device ids are NEW against the known baseline.
|
||||
* No baseline yet (first run / upgrade) → nothing is new: every current id
|
||||
* becomes the baseline silently, so an update never floods the plan with dots.
|
||||
*/
|
||||
export function diffNewDevices(
|
||||
currentIds: string[],
|
||||
known: string[] | null | undefined,
|
||||
): { fresh: string[]; known: string[] } {
|
||||
if (!Array.isArray(known)) return { fresh: [], known: [...currentIds] };
|
||||
const knownSet = new Set(known);
|
||||
const fresh = currentIds.filter((id) => !knownSet.has(id));
|
||||
return { fresh, known: fresh.length ? [...known, ...fresh] : known };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user