From 7233d15ba019afab72e9e0f188f24b306f832282 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Thu, 25 May 2023 16:19:33 +0600 Subject: [PATCH] UBER-241 UBER-244 UBER-245 UBER-246 Inbox fixes (#3256) Signed-off-by: Denis Bykhov --- .../src/components/EmployeeInbox.svelte | 5 ++-- .../components/NotificationPresenter.svelte | 2 +- .../src/components/NotificationView.svelte | 16 +++++----- .../components/PeopleNotificationsView.svelte | 30 ++++++++++--------- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/plugins/notification-resources/src/components/EmployeeInbox.svelte b/plugins/notification-resources/src/components/EmployeeInbox.svelte index 92a1ff1c2c..82df6678ca 100644 --- a/plugins/notification-resources/src/components/EmployeeInbox.svelte +++ b/plugins/notification-resources/src/components/EmployeeInbox.svelte @@ -115,9 +115,8 @@ const client = getClient() async function openDM () { - const current = (await client.findAll(chunter.class.DirectMessage, { members: accountId })).find( - (p) => p.members.length === 2 - ) + const res = await client.findAll(chunter.class.DirectMessage, { members: accountId }) + const current = res.find((p) => p.members.includes(me) && p.members.length === 2) if (current !== undefined) { dispatch('dm', current._id) } else { diff --git a/plugins/notification-resources/src/components/NotificationPresenter.svelte b/plugins/notification-resources/src/components/NotificationPresenter.svelte index d2d58f9389..06798c001d 100644 --- a/plugins/notification-resources/src/components/NotificationPresenter.svelte +++ b/plugins/notification-resources/src/components/NotificationPresenter.svelte @@ -24,7 +24,7 @@ const store = notificationClient.docUpdatesStore $: docUpdate = $store.get(value._id) - $: hasNotification = (docUpdate?.txes?.length ?? 0) > 0 && docUpdate?.hidden !== true + $: hasNotification = docUpdate?.txes?.some((p) => p.isNew) && docUpdate?.hidden !== true {#if hasNotification} diff --git a/plugins/notification-resources/src/components/NotificationView.svelte b/plugins/notification-resources/src/components/NotificationView.svelte index ce04f0faf1..cb500591c4 100644 --- a/plugins/notification-resources/src/components/NotificationView.svelte +++ b/plugins/notification-resources/src/components/NotificationView.svelte @@ -34,8 +34,10 @@ const client = getClient() const hierarchy = client.getHierarchy() - $: value.txes[0] && - client.findOne(core.class.TxCUD, { _id: value.txes[0]._id }).then((res) => { + $: txRef = value.txes[value.txes.length - 1]._id + + $: txRef && + client.findOne(core.class.TxCUD, { _id: txRef }).then((res) => { if (res !== undefined) { tx = TxProcessor.extractTx(res) as TxCUD } else { @@ -64,9 +66,9 @@ -
-
- {#if doc} +{#if doc} +
+
- {/if} -
+
+{/if}