diff --git a/plugins/notification-resources/src/components/Activity.svelte b/plugins/notification-resources/src/components/Activity.svelte index eeb63c6cf2..ae2c193539 100644 --- a/plugins/notification-resources/src/components/Activity.svelte +++ b/plugins/notification-resources/src/components/Activity.svelte @@ -68,6 +68,7 @@ changeSelected(selected) } else { selected = index + markAsRead(selected) } } } @@ -76,11 +77,20 @@ $: changeSelected(selected) + function markAsRead (index: number) { + if (filtered[index] !== undefined) { + filtered[index].txes.forEach((p) => (p.isNew = false)) + filtered[index].txes = filtered[index].txes + filtered = filtered + } + } + function changeSelected (index: number) { if (filtered[index] !== undefined) { listProvider.updateFocus(filtered[index]) _id = filtered[index]?.attachedTo dispatch('change', filtered[index]) + markAsRead(index) } else if (filtered.length) { if (index < filtered.length - 1) { selected++ diff --git a/plugins/notification-resources/src/components/EmployeeInbox.svelte b/plugins/notification-resources/src/components/EmployeeInbox.svelte index e10074d12c..310c74e145 100644 --- a/plugins/notification-resources/src/components/EmployeeInbox.svelte +++ b/plugins/notification-resources/src/components/EmployeeInbox.svelte @@ -64,6 +64,7 @@ changeSelected(selected) } else { selected = index + markAsRead(selected) } } loading = false @@ -77,11 +78,20 @@ $: changeSelected(selected) + function markAsRead (index: number) { + if (docs[index] !== undefined) { + docs[index].txes.forEach((p) => (p.isNew = false)) + docs[index].txes = docs[index].txes + docs = docs + } + } + function changeSelected (index: number) { if (docs[index] !== undefined) { listProvider.updateFocus(docs[index]) _id = docs[index]?.attachedTo dispatch('change', docs[index]) + markAsRead(index) } else if (docs.length) { if (index < docs.length - 1) { selected++ diff --git a/plugins/notification-resources/src/components/Inbox.svelte b/plugins/notification-resources/src/components/Inbox.svelte index 721747092c..35ecace62e 100644 --- a/plugins/notification-resources/src/components/Inbox.svelte +++ b/plugins/notification-resources/src/components/Inbox.svelte @@ -49,7 +49,7 @@ let _id: Ref | undefined let _class: Ref> | undefined let selectedEmployee: Ref | undefined = undefined - const prevValue: DocUpdates | undefined = undefined + let prevValue: DocUpdates | undefined = undefined async function select (value: DocUpdates | undefined) { if (!value) { @@ -59,14 +59,16 @@ return } if (prevValue !== undefined) { - await client.update(prevValue, { txes: prevValue.txes }) + prevValue.txes.forEach((p) => (p.isNew = false)) + const txes = prevValue.txes + await client.update(prevValue, { txes }) } const targetClass = hierarchy.getClass(value.attachedToClass) const panelComponent = hierarchy.as(targetClass, view.mixin.ObjectPanel) component = panelComponent.component ?? view.component.EditDoc _id = value.attachedTo _class = value.attachedToClass - value.txes.forEach((p) => (p.isNew = false)) + prevValue = value } function openDM (value: Ref) {