Ensure receiver devices are consistently sorted

This commit is contained in:
hensm
2022-08-28 01:31:44 +01:00
parent f7b6fd7a37
commit 48d5e7e0fe

View File

@@ -138,6 +138,14 @@ export default new (class extends TypedEventTarget<EventMap> {
const { deviceId, deviceInfo } = message.data;
this.receiverDevices.set(deviceId, deviceInfo);
// Sort devices by friendly name
this.receiverDevices = new Map(
[...this.receiverDevices].sort(([, deviceA], [, deviceB]) =>
deviceA.friendlyName.localeCompare(deviceB.friendlyName)
)
);
this.dispatchEvent(
new CustomEvent("deviceUp", {
detail: { deviceInfo }