mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
Fix live logbook starting empty (#12833)
This commit is contained in:
parent
ceda911670
commit
077fa3f6b2
@ -310,7 +310,7 @@ export class HaLogbook extends LitElement {
|
||||
// Put newest ones on top. Reverse works in-place so
|
||||
// make a copy first.
|
||||
const newEntries = [...streamMessage.events].reverse();
|
||||
if (!this._logbookEntries) {
|
||||
if (!this._logbookEntries || !this._logbookEntries.length) {
|
||||
this._logbookEntries = newEntries;
|
||||
return;
|
||||
}
|
||||
@ -320,8 +320,10 @@ export class HaLogbook extends LitElement {
|
||||
return;
|
||||
}
|
||||
const nonExpiredRecords = this._nonExpiredRecords(purgeBeforePythonTime);
|
||||
this._logbookEntries =
|
||||
newEntries[0].when >= this._logbookEntries[0].when
|
||||
this._logbookEntries = !nonExpiredRecords.length
|
||||
? // All existing entries expired
|
||||
newEntries
|
||||
: newEntries[0].when >= nonExpiredRecords[0].when
|
||||
? // The new records are newer than the old records
|
||||
// append the old records to the end of the new records
|
||||
newEntries.concat(nonExpiredRecords)
|
||||
|
Loading…
x
Reference in New Issue
Block a user