Sort addons in backup by name (#23442)

* Sort addons in backup by name

* Update ha-backup-addons-picker.ts
This commit is contained in:
Bram Kragten 2024-12-24 15:44:27 +01:00 committed by GitHub
parent 7150016375
commit f7dbd38c2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,7 +2,9 @@ import { mdiPuzzle } from "@mdi/js";
import type { CSSResultGroup } from "lit";
import { LitElement, css, html } from "lit";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../../../common/dom/fire_event";
import { stringCompare } from "../../../../common/string/compare";
import "../../../../components/ha-checkbox";
import type { HaCheckbox } from "../../../../components/ha-checkbox";
import "../../../../components/ha-formfield";
@ -29,10 +31,16 @@ export class HaBackupAddonsPicker extends LitElement {
@property({ attribute: "hide-version", type: Boolean })
public hideVersion = false;
private _addons = memoizeOne((addons: BackupAddonItem[]) =>
addons.sort((a, b) =>
stringCompare(a.name, b.name, this.hass.locale.language)
)
);
protected render() {
return html`
<div class="items">
${this.addons.map(
${this._addons(this.addons).map(
(item) => html`
<ha-formfield>
<ha-backup-formfield-label