diff --git a/plugins/chunter-resources/src/components/Channel.svelte b/plugins/chunter-resources/src/components/Channel.svelte index 5b8cbfe43b..784bcce7a4 100644 --- a/plugins/chunter-resources/src/components/Channel.svelte +++ b/plugins/chunter-resources/src/components/Channel.svelte @@ -92,7 +92,7 @@ skipLabels={!isDocChannel} selectedFilters={filters} startFromBottom - {selectedMessageId} + bind:selectedMessageId {collection} provider={dataProvider} {isAsideOpened} diff --git a/plugins/chunter-resources/src/components/ChannelHeader.svelte b/plugins/chunter-resources/src/components/ChannelHeader.svelte index f2edfffd7c..7dacde2606 100644 --- a/plugins/chunter-resources/src/components/ChannelHeader.svelte +++ b/plugins/chunter-resources/src/components/ChannelHeader.svelte @@ -78,7 +78,7 @@ on:aside-toggled on:close > - + diff --git a/plugins/chunter-resources/src/components/ChannelScrollView.svelte b/plugins/chunter-resources/src/components/ChannelScrollView.svelte index 15bb9b6321..33aa04658b 100644 --- a/plugins/chunter-resources/src/components/ChannelScrollView.svelte +++ b/plugins/chunter-resources/src/components/ChannelScrollView.svelte @@ -55,7 +55,7 @@ export let scrollElement: HTMLDivElement | undefined = undefined export let startFromBottom = false export let selectedFilters: Ref[] = [] - export let withDates: boolean = true + export let embedded = false export let collection: string | undefined = undefined export let showEmbedded = false export let skipLabels = false @@ -355,7 +355,7 @@ } function updateSelectedDate (): void { - if (!withDates) { + if (embedded) { return } @@ -468,13 +468,13 @@ if (isLoading || !isScrollInitialized || isInitialScrolling) { return } - const msg = messages.find(({ _id }) => _id === selectedMessageId) + const msg = $metadataStore.find(({ _id }) => _id === selectedMessageId) if (msg !== undefined) { const isReload = provider.jumpToMessage(msg) if (isReload) { reinitializeScroll() } - } else { + } else if (selectedMessageId === undefined) { provider.jumpToEnd() reinitializeScroll() } @@ -677,7 +677,7 @@ {#if startFromBottom}
{/if} - {#if withDates && displayMessages.length > 0 && selectedDate} + {#if !embedded && displayMessages.length > 0 && selectedDate}
@@ -702,7 +702,7 @@ {/if} - {#if displayMessages.length === 0 && !hierarchy.isDerived(objectClass, activity.class.ActivityMessage)} + {#if displayMessages.length === 0 && !embedded} {/if} - {#if withDates && message.createdOn && $datesStore.includes(message.createdOn)} + {#if !embedded && message.createdOn && $datesStore.includes(message.createdOn)} {/if} @@ -741,7 +741,7 @@ {/if} - {#if showScrollDownButton} + {#if !embedded && showScrollDownButton}
): Promise { + const message = event.detail + + if (isThreadMessage(message)) { + const location = getCurrentLocation() + location.path[4] = message.attachedTo + navigate(location) + } + + messageInFocus.set(message._id) + }
@@ -89,6 +105,7 @@ canOpen={isDocChat} {isAsideShown} on:close + on:select={handleMessageSelect} on:aside-toggled={() => { isAsideShown = !isAsideShown }} diff --git a/plugins/chunter-resources/src/components/PinnedMessages.svelte b/plugins/chunter-resources/src/components/PinnedMessages.svelte index 257b6dfd7c..77336f8d24 100644 --- a/plugins/chunter-resources/src/components/PinnedMessages.svelte +++ b/plugins/chunter-resources/src/components/PinnedMessages.svelte @@ -19,32 +19,53 @@ import activity, { ActivityMessage } from '@hcengineering/activity' import { Class, Doc, Ref } from '@hcengineering/core' import view from '@hcengineering/view' + import { ThreadMessage } from '@hcengineering/chunter' + import { createEventDispatcher } from 'svelte' import chunter from '../plugin' export let _class: Ref> export let _id: Ref + const dispatch = createEventDispatcher() const pinnedQuery = createQuery() + const pinnedThreadsQuery = createQuery() let pinnedMessagesCount = 0 + let pinnedThreadsCount = 0 $: pinnedQuery.query( activity.class.ActivityMessage, { attachedTo: _id, isPinned: true }, (res: ActivityMessage[]) => { pinnedMessagesCount = res.length - } + }, + { projection: { _id: 1, attachedTo: 1, isPinned: 1 } } ) + + $: pinnedThreadsQuery.query( + chunter.class.ThreadMessage, + { objectId: _id, isPinned: true }, + (res: ThreadMessage[]) => { + pinnedThreadsCount = res.length + }, + { projection: { _id: 1, objectId: 1, isPinned: 1 } } + ) + function openMessagesPopup (ev: MouseEvent) { - showPopup(PinnedMessagesPopup, { attachedTo: _id, attachedToClass: _class }, eventToHTMLElement(ev)) + showPopup(PinnedMessagesPopup, { attachedTo: _id, attachedToClass: _class }, eventToHTMLElement(ev), (result) => { + if (result == null) return + dispatch('select', result) + }) } + + $: count = pinnedMessagesCount + pinnedThreadsCount -{#if pinnedMessagesCount > 0} +{#if count > 0}
- + {/if} diff --git a/plugins/chunter-resources/src/components/PinnedMessagesPopup.svelte b/plugins/chunter-resources/src/components/PinnedMessagesPopup.svelte index ae599394ea..b1093d1b00 100644 --- a/plugins/chunter-resources/src/components/PinnedMessagesPopup.svelte +++ b/plugins/chunter-resources/src/components/PinnedMessagesPopup.svelte @@ -13,12 +13,13 @@ // limitations under the License. -->