mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 09:16:38 +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
|
// Put newest ones on top. Reverse works in-place so
|
||||||
// make a copy first.
|
// make a copy first.
|
||||||
const newEntries = [...streamMessage.events].reverse();
|
const newEntries = [...streamMessage.events].reverse();
|
||||||
if (!this._logbookEntries) {
|
if (!this._logbookEntries || !this._logbookEntries.length) {
|
||||||
this._logbookEntries = newEntries;
|
this._logbookEntries = newEntries;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -320,14 +320,16 @@ export class HaLogbook extends LitElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const nonExpiredRecords = this._nonExpiredRecords(purgeBeforePythonTime);
|
const nonExpiredRecords = this._nonExpiredRecords(purgeBeforePythonTime);
|
||||||
this._logbookEntries =
|
this._logbookEntries = !nonExpiredRecords.length
|
||||||
newEntries[0].when >= this._logbookEntries[0].when
|
? // All existing entries expired
|
||||||
? // The new records are newer than the old records
|
newEntries
|
||||||
// append the old records to the end of the new records
|
: newEntries[0].when >= nonExpiredRecords[0].when
|
||||||
newEntries.concat(nonExpiredRecords)
|
? // The new records are newer than the old records
|
||||||
: // The new records are older than the old records
|
// append the old records to the end of the new records
|
||||||
// append the new records to the end of the old records
|
newEntries.concat(nonExpiredRecords)
|
||||||
nonExpiredRecords.concat(newEntries);
|
: // The new records are older than the old records
|
||||||
|
// append the new records to the end of the old records
|
||||||
|
nonExpiredRecords.concat(newEntries);
|
||||||
};
|
};
|
||||||
|
|
||||||
private _updateTraceContexts = throttle(async () => {
|
private _updateTraceContexts = throttle(async () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user