From e51d0f3ae4be2277ec3820a90a62d933c012ff5b Mon Sep 17 00:00:00 2001 From: Kristina Date: Tue, 30 Jul 2024 11:02:06 +0400 Subject: [PATCH] [Part 1]: Add space to activity queries/finds (#6177) Signed-off-by: Kristina Fefelova --- .../src/components/Activity.svelte | 4 +-- .../src/channelDataProvider.ts | 15 ++++++---- .../src/components/Channel.svelte | 5 ++-- .../src/components/ChannelHeader.svelte | 5 ++-- .../src/components/ChannelPreview.svelte | 3 +- .../src/components/ChannelScrollView.svelte | 2 +- .../src/components/Header.svelte | 3 +- .../src/components/PinnedMessages.svelte | 28 ++++++++++++------- .../src/components/PinnedMessagesPopup.svelte | 19 ++++++++----- .../chat-message/ChatMessageInput.svelte | 22 +++++++++------ .../chat-message/ChatMessagePopup.svelte | 3 +- .../src/components/threads/ThreadView.svelte | 15 ++++++---- plugins/chunter-resources/src/utils.ts | 6 +++- .../notification-resources/src/index.ts | 2 +- 14 files changed, 82 insertions(+), 50 deletions(-) diff --git a/plugins/activity-resources/src/components/Activity.svelte b/plugins/activity-resources/src/components/Activity.svelte index b378c40a00..f1431e5360 100644 --- a/plugins/activity-resources/src/components/Activity.svelte +++ b/plugins/activity-resources/src/components/Activity.svelte @@ -15,7 +15,7 @@ diff --git a/plugins/chunter-resources/src/components/ChannelHeader.svelte b/plugins/chunter-resources/src/components/ChannelHeader.svelte index 7d8aa8f1dc..61f19b514b 100644 --- a/plugins/chunter-resources/src/components/ChannelHeader.svelte +++ b/plugins/chunter-resources/src/components/ChannelHeader.svelte @@ -74,9 +74,10 @@ {canOpen} {withAside} {isAsideShown} - hideBefore on:aside-toggled on:close > - + {#if object} + + {/if} diff --git a/plugins/chunter-resources/src/components/ChannelPreview.svelte b/plugins/chunter-resources/src/components/ChannelPreview.svelte index b9f57fbc67..370e22955d 100644 --- a/plugins/chunter-resources/src/components/ChannelPreview.svelte +++ b/plugins/chunter-resources/src/components/ChannelPreview.svelte @@ -20,6 +20,7 @@ import { ActivityMessagePresenter } from '@hcengineering/activity-resources' import chunterResources from '../plugin' + import { getChannelSpace } from '../utils' export let object: DirectMessage @@ -29,7 +30,7 @@ const messagesQuery = createQuery() $: messagesQuery.query( chunter.class.ChatMessage, - { attachedTo: object._id }, + { attachedTo: object._id, space: getChannelSpace(object._class, object._id, object.space) }, (res) => { if (res !== undefined) { messages = res.sort((a, b) => (a.createdOn ?? 0) - (b.createdOn ?? 0)) diff --git a/plugins/chunter-resources/src/components/ChannelScrollView.svelte b/plugins/chunter-resources/src/components/ChannelScrollView.svelte index eff16efd66..7cca7d64fa 100644 --- a/plugins/chunter-resources/src/components/ChannelScrollView.svelte +++ b/plugins/chunter-resources/src/components/ChannelScrollView.svelte @@ -726,7 +726,7 @@ onScroll={handleScroll} onResize={handleResize} > - {#if loadMoreAllowed} + {#if loadMoreAllowed && !embedded} {/if} diff --git a/plugins/chunter-resources/src/components/Header.svelte b/plugins/chunter-resources/src/components/Header.svelte index d4470a0658..bc258f5980 100644 --- a/plugins/chunter-resources/src/components/Header.svelte +++ b/plugins/chunter-resources/src/components/Header.svelte @@ -50,7 +50,6 @@ export let withFilters: boolean = false export let filters: Ref[] = [] export let adaptive: 'default' | 'freezeActions' | 'doubleRow' | 'disabled' = 'default' - export let hideBefore: boolean = false export let hideActions: boolean = false const client = getClient() @@ -63,7 +62,7 @@
export let _class: Ref> export let _id: Ref @@ -34,29 +36,35 @@ let pinnedMessagesCount = 0 let pinnedThreadsCount = 0 + $: channelSpace = getChannelSpace(_class, _id, space) $: pinnedQuery.query( activity.class.ActivityMessage, - { attachedTo: _id, isPinned: true }, + { attachedTo: _id, isPinned: true, space: channelSpace }, (res: ActivityMessage[]) => { pinnedMessagesCount = res.length }, - { projection: { _id: 1, attachedTo: 1, isPinned: 1 } } + { projection: { _id: 1, space: 1, attachedTo: 1, isPinned: 1 } } ) $: pinnedThreadsQuery.query( chunter.class.ThreadMessage, - { objectId: _id, isPinned: true }, + { objectId: _id, isPinned: true, space: channelSpace }, (res: ThreadMessage[]) => { pinnedThreadsCount = res.length }, - { projection: { _id: 1, objectId: 1, isPinned: 1 } } + { projection: { _id: 1, space: 1, objectId: 1, isPinned: 1 } } ) - function openMessagesPopup (ev: MouseEvent) { - showPopup(PinnedMessagesPopup, { attachedTo: _id, attachedToClass: _class }, eventToHTMLElement(ev), (result) => { - if (result == null) return - dispatch('select', result) - }) + function openMessagesPopup (ev: MouseEvent): void { + showPopup( + PinnedMessagesPopup, + { attachedTo: _id, attachedToClass: _class, space: channelSpace }, + eventToHTMLElement(ev), + (result) => { + if (result == null) return + dispatch('select', result) + } + ) } $: count = pinnedMessagesCount + pinnedThreadsCount diff --git a/plugins/chunter-resources/src/components/PinnedMessagesPopup.svelte b/plugins/chunter-resources/src/components/PinnedMessagesPopup.svelte index b1093d1b00..b49e48bbc8 100644 --- a/plugins/chunter-resources/src/components/PinnedMessagesPopup.svelte +++ b/plugins/chunter-resources/src/components/PinnedMessagesPopup.svelte @@ -14,17 +14,18 @@ -->