mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Use modern stringCompare for device/service sorting per reviewer feedback
Co-authored-by: balloob <1444314+balloob@users.noreply.github.com>
This commit is contained in:
parent
8ad8eea034
commit
72841dc787
@ -22,7 +22,7 @@ import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { caseInsensitiveStringCompare } from "../../../common/string/compare";
|
||||
import { stringCompare } from "../../../common/string/compare";
|
||||
import { computeDeviceNameDisplay } from "../../../common/entity/compute_device_name";
|
||||
import { isDevVersion } from "../../../common/config/version";
|
||||
import {
|
||||
@ -500,7 +500,7 @@ class HaConfigEntryRow extends LitElement {
|
||||
device.entry_type !== "service"
|
||||
)
|
||||
.sort((a, b) =>
|
||||
caseInsensitiveStringCompare(
|
||||
stringCompare(
|
||||
computeDeviceNameDisplay(a, this.hass),
|
||||
computeDeviceNameDisplay(b, this.hass),
|
||||
this.hass.locale.language
|
||||
@ -515,7 +515,7 @@ class HaConfigEntryRow extends LitElement {
|
||||
device.entry_type === "service"
|
||||
)
|
||||
.sort((a, b) =>
|
||||
caseInsensitiveStringCompare(
|
||||
stringCompare(
|
||||
computeDeviceNameDisplay(a, this.hass),
|
||||
computeDeviceNameDisplay(b, this.hass),
|
||||
this.hass.locale.language
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { computeDeviceNameDisplay } from "../../../../src/common/entity/compute_device_name";
|
||||
import { caseInsensitiveStringCompare } from "../../../../src/common/string/compare";
|
||||
import { stringCompare } from "../../../../src/common/string/compare";
|
||||
import type { DeviceRegistryEntry } from "../../../../src/data/device_registry";
|
||||
|
||||
describe("Device sorting in ha-config-entry-row", () => {
|
||||
@ -59,7 +59,7 @@ describe("Device sorting in ha-config-entry-row", () => {
|
||||
|
||||
// Sort using the same logic as our implementation
|
||||
const sortedDevices = devices.sort((a, b) =>
|
||||
caseInsensitiveStringCompare(
|
||||
stringCompare(
|
||||
computeDeviceNameDisplay(a, mockHass),
|
||||
computeDeviceNameDisplay(b, mockHass),
|
||||
mockHass.locale.language
|
||||
@ -93,7 +93,7 @@ describe("Device sorting in ha-config-entry-row", () => {
|
||||
];
|
||||
|
||||
const sortedDevices = devices.sort((a, b) =>
|
||||
caseInsensitiveStringCompare(
|
||||
stringCompare(
|
||||
computeDeviceNameDisplay(a, mockHass),
|
||||
computeDeviceNameDisplay(b, mockHass),
|
||||
mockHass.locale.language
|
||||
@ -117,7 +117,7 @@ describe("Device sorting in ha-config-entry-row", () => {
|
||||
];
|
||||
|
||||
const sortedServices = services.sort((a, b) =>
|
||||
caseInsensitiveStringCompare(
|
||||
stringCompare(
|
||||
computeDeviceNameDisplay(a, mockHass),
|
||||
computeDeviceNameDisplay(b, mockHass),
|
||||
mockHass.locale.language
|
||||
|
Loading…
x
Reference in New Issue
Block a user