Skip to content

Commit

Permalink
Refresh versions on opening panel and remove duplicate users from agg…
Browse files Browse the repository at this point in the history
…regate
  • Loading branch information
bosschaert committed Apr 5, 2024
1 parent ec65f4f commit 461508f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions blocks/edit/da-content/da-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export default class DaContent extends LitElement {
e.target.parentElement.classList.add('show-versions');

const dav = this.shadowRoot.querySelector('da-versions');
// Force an update on the versions panel to load the latest versions
dav.requestUpdate();

dav.classList.add('show-versions');

// No need to request an update, setting the path is enough as its a reactive property
Expand Down
11 changes: 8 additions & 3 deletions blocks/edit/da-versions/da-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,18 @@ export default class DaVersions extends LitElement {
aggregatedTo: list[end - 1].timestamp,
aggregateID: `${start}-${end}`,
};
const users = new Set();
const users = [];

for (let i = start; i < end; i += 1) {
list[i].users.forEach((e) => users.add(e));
list[i].users.forEach((e) => users.push(e));
list[i].parent = agg.aggregateID;
}
agg.users = [...users];

// remove duplicates
agg.users = users.filter((val, idx) => {
const v = JSON.stringify(val);
return idx === users.findIndex((obj) => JSON.stringify(obj) === v);
});

list.splice(start, 0, agg);
}
Expand Down

0 comments on commit 461508f

Please sign in to comment.