Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix-update-on-entity-delete #105

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions flex-table-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ class FlexTableCard extends HTMLElement {

// Used to detect changes requiring a table refresh.
#old_last_updated = "";
#old_rowcount = 0;

_getRegEx(pats, invert=false) {
// compile and convert wildcardish-regex to real RegExp
Expand Down Expand Up @@ -572,10 +573,14 @@ class FlexTableCard extends HTMLElement {

// Check for changes requiring a table refresh.
// Return if no changes detected.
let last_updated_arr = entities.map(a => a.last_updated);
let max = last_updated_arr.sort().slice(-1)[0];
if (max == this.#old_last_updated) return;
this.#old_last_updated = max;
let rowcount = entities.length;
if (rowcount == this.#old_rowcount) {
let last_updated_arr = entities.map(a => a.last_updated);
let max = last_updated_arr.sort().slice(-1)[0];
if (max == this.#old_last_updated) return;
this.#old_last_updated = max;
}
this.#old_rowcount = rowcount;

// `raw_rows` to be filled with data here, due to 'attr_as_list' it is possible to have
// multiple data `raw_rows` acquired into one cell(.raw_data), so re-iterate all rows
Expand Down