From b9d8a7a6e5e7fe7200c722bead1eca26c353e05a Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Tue, 30 May 2023 17:05:17 +0600 Subject: [PATCH] UBER-293 inbox selection fix (#3287) Signed-off-by: Denis Bykhov --- .../src/components/Activity.svelte | 9 +++++++-- .../src/components/EmployeeInbox.svelte | 9 +++++++-- .../src/components/People.svelte | 13 +++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-) 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 + } + } } }