diff --git a/plugins/notification-resources/src/components/Activity.svelte b/plugins/notification-resources/src/components/Activity.svelte index 7db752cfa5..c14591537b 100644 --- a/plugins/notification-resources/src/components/Activity.svelte +++ b/plugins/notification-resources/src/components/Activity.svelte @@ -62,8 +62,13 @@ listProvider.update(filtered) if (loading || _id === undefined) { changeSelected(selected) - } else if (filtered.find((p) => p.attachedTo === _id) === undefined) { - changeSelected(selected) + } else { + const index = filtered.findIndex((p) => p.attachedTo === _id) + if (index === -1) { + changeSelected(selected) + } else { + selected = index + } } } diff --git a/plugins/notification-resources/src/components/EmployeeInbox.svelte b/plugins/notification-resources/src/components/EmployeeInbox.svelte index 11423833df..1968a5e341 100644 --- a/plugins/notification-resources/src/components/EmployeeInbox.svelte +++ b/plugins/notification-resources/src/components/EmployeeInbox.svelte @@ -58,8 +58,13 @@ listProvider.update(docs) if (loading || _id === undefined) { changeSelected(selected) - } else if (docs.find((p) => p.attachedTo === _id) === undefined) { - changeSelected(selected) + } else { + const index = docs.findIndex((p) => p.attachedTo === _id) + if (index === -1) { + changeSelected(selected) + } else { + selected = index + } } loading = false }, diff --git a/plugins/notification-resources/src/components/People.svelte b/plugins/notification-resources/src/components/People.svelte index a9a2477d96..e06d240025 100644 --- a/plugins/notification-resources/src/components/People.svelte +++ b/plugins/notification-resources/src/components/People.svelte @@ -92,8 +92,17 @@ .filter((p) => p !== undefined) as EmployeeAccount[] if (loading || _id === undefined) { changeSelected(selected) - } else if (filtered.find((p) => p.attachedTo === _id) === undefined) { - changeSelected(selected) + } else { + const index = filtered.findIndex((p) => p.attachedTo === _id) + if (index === -1) { + changeSelected(selected) + } else { + const doc = filtered[index] + const acc = accounts.findIndex((p) => p._id === doc.txes[doc.txes.length - 1].modifiedBy) + if (acc !== -1) { + selected = acc + } + } } }