Sort persistent notifications ascending (#7195)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
Tomasz 2020-10-17 22:03:33 +02:00 committed by GitHub
parent 02d37a369a
commit 288bf6805a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -176,7 +176,22 @@ export class HuiNotificationDrawer extends EventsMixin(
.filter((entityId) => computeDomain(entityId) === "configurator") .filter((entityId) => computeDomain(entityId) === "configurator")
.map((entityId) => hass.states[entityId]); .map((entityId) => hass.states[entityId]);
return notificationsBackend.concat(configuratorEntities); const notifications = notificationsBackend.concat(configuratorEntities);
notifications.sort(function (n1, n2) {
const d1 = new Date(n1.created_at);
const d2 = new Date(n2.created_at);
if (d1 < d2) {
return 1;
}
if (d1 > d2) {
return -1;
}
return 0;
});
return notifications;
} }
showDialog({ narrow }) { showDialog({ narrow }) {