mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-03 17:05:16 +03:00
UBERF-5393: fix backlink for thread (#4578)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
60da5e28e3
commit
57ee6f5f49
@ -414,7 +414,7 @@ export function createModel (builder: Builder, options = { addApplication: true
|
||||
}
|
||||
|
||||
builder.mixin(chunter.class.ThreadMessage, core.class.Class, view.mixin.LinkProvider, {
|
||||
encode: chunter.function.GetFragment
|
||||
encode: chunter.function.GetThreadLink
|
||||
})
|
||||
|
||||
createAction(
|
||||
|
@ -108,7 +108,8 @@ export default mergeIds(chunterId, chunter, {
|
||||
CanDeleteMessage: '' as Resource<(doc?: Doc | Doc[]) => Promise<boolean>>,
|
||||
CanReplyToThread: '' as Resource<(doc?: Doc | Doc[]) => Promise<boolean>>,
|
||||
CanCopyMessageLink: '' as Resource<(doc?: Doc | Doc[]) => Promise<boolean>>,
|
||||
GetChunterSpaceLinkFragment: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>
|
||||
GetChunterSpaceLinkFragment: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
|
||||
GetThreadLink: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>
|
||||
},
|
||||
filter: {
|
||||
BacklinksFilter: '' as Resource<(message: ActivityMessage, _class?: Ref<Doc>) => boolean>,
|
||||
|
@ -16,7 +16,7 @@
|
||||
import { Person } from '@hcengineering/contact'
|
||||
import { personByIdStore, Avatar } from '@hcengineering/contact-resources'
|
||||
import { Doc, IdMap, Ref, WithLookup } from '@hcengineering/core'
|
||||
import { getLocation, Label, TimeSince } from '@hcengineering/ui'
|
||||
import { getLocation, Label, navigate, TimeSince } from '@hcengineering/ui'
|
||||
import activity, { ActivityMessage } from '@hcengineering/activity'
|
||||
import notification, {
|
||||
ActivityInboxNotification,
|
||||
@ -27,7 +27,7 @@
|
||||
import { getResource } from '@hcengineering/platform'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
import { navigateToThread } from '../utils'
|
||||
import { buildThreadLink } from '../utils'
|
||||
|
||||
export let object: ActivityMessage
|
||||
export let embedded = false
|
||||
@ -97,7 +97,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
navigateToThread(getLocation(), context._id, object._id)
|
||||
navigate(buildThreadLink(getLocation(), context._id, object._id))
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -14,8 +14,13 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { ThreadMessage } from '@hcengineering/chunter'
|
||||
import { Action, Label } from '@hcengineering/ui'
|
||||
import { getDocLinkTitle } from '@hcengineering/view-resources'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import activity from '@hcengineering/activity'
|
||||
|
||||
import chunter from '../../plugin'
|
||||
import ChatMessagePresenter from '../chat-message/ChatMessagePresenter.svelte'
|
||||
import { Action } from '@hcengineering/ui'
|
||||
|
||||
export let value: ThreadMessage | undefined
|
||||
export let showNotify: boolean = false
|
||||
@ -30,11 +35,27 @@
|
||||
export let actions: Action[] = []
|
||||
export let excludedActions: string[] = []
|
||||
export let hoverable = true
|
||||
export let inline = false
|
||||
export let hoverStyles: 'borderedHover' | 'filledHover' = 'borderedHover'
|
||||
export let onClick: (() => void) | undefined = undefined
|
||||
export let onReply: (() => void) | undefined = undefined
|
||||
|
||||
const client = getClient()
|
||||
</script>
|
||||
|
||||
{#if inline && value}
|
||||
{#await getDocLinkTitle(client, value.objectId, value.objectClass) then title}
|
||||
<span>
|
||||
<span class="lower">
|
||||
<Label label={chunter.string.Thread} />
|
||||
</span>
|
||||
<span class="lower">
|
||||
<Label label={activity.string.In} />
|
||||
</span>
|
||||
{title}
|
||||
</span>
|
||||
{/await}
|
||||
{:else}
|
||||
<ChatMessagePresenter
|
||||
{value}
|
||||
{showNotify}
|
||||
@ -53,3 +74,4 @@
|
||||
{onClick}
|
||||
{onReply}
|
||||
/>
|
||||
{/if}
|
||||
|
@ -82,7 +82,8 @@ import {
|
||||
getTitle,
|
||||
getUnreadThreadsCount,
|
||||
canCopyMessageLink,
|
||||
navigateToThread
|
||||
buildThreadLink,
|
||||
getThreadLink
|
||||
} from './utils'
|
||||
import { InboxNotificationsClientImpl } from '@hcengineering/notification-resources'
|
||||
import { type Mode } from './components/chat/types'
|
||||
@ -244,7 +245,7 @@ export async function replyToThread (message: ActivityMessage): Promise<void> {
|
||||
loc.path[2] = chunterId
|
||||
}
|
||||
|
||||
navigateToThread(loc, contextId, message._id)
|
||||
navigate(buildThreadLink(loc, contextId, message._id))
|
||||
}
|
||||
|
||||
export default async (): Promise<Resources> => ({
|
||||
@ -297,7 +298,8 @@ export default async (): Promise<Resources> => ({
|
||||
CanReplyToThread: canReplyToThread,
|
||||
CanCopyMessageLink: canCopyMessageLink,
|
||||
GetChunterSpaceLinkFragment: chunterSpaceLinkFragmentProvider,
|
||||
GetUnreadThreadsCount: getUnreadThreadsCount
|
||||
GetUnreadThreadsCount: getUnreadThreadsCount,
|
||||
GetThreadLink: getThreadLink
|
||||
},
|
||||
activity: {
|
||||
BacklinkCreatedLabel
|
||||
|
@ -51,7 +51,7 @@ import activity, {
|
||||
type DocUpdateMessage
|
||||
} from '@hcengineering/activity'
|
||||
import { InboxNotificationsClientImpl } from '@hcengineering/notification-resources'
|
||||
import { type DocNotifyContext, inboxId } from '@hcengineering/notification'
|
||||
import notification, { type DocNotifyContext, inboxId } from '@hcengineering/notification'
|
||||
import { get, type Unsubscriber } from 'svelte/store'
|
||||
|
||||
import chunter from './plugin'
|
||||
@ -380,14 +380,13 @@ export async function filterChatMessages (
|
||||
return messages.filter((message) => filtersFns.some((filterFn) => filterFn(message, objectClass)))
|
||||
}
|
||||
|
||||
export function navigateToThread (loc: Location, contextId: Ref<DocNotifyContext>, _id: Ref<ActivityMessage>): void {
|
||||
export function buildThreadLink (loc: Location, contextId: Ref<DocNotifyContext>, _id: Ref<ActivityMessage>): Location {
|
||||
const specials = chatSpecials.map(({ id }) => id)
|
||||
|
||||
if (loc.path[2] === chunterId && specials.includes(loc.path[3])) {
|
||||
loc.path[4] = _id
|
||||
loc.query = { message: _id }
|
||||
navigate(loc)
|
||||
return
|
||||
return loc
|
||||
}
|
||||
|
||||
if (loc.path[2] !== inboxId) {
|
||||
@ -398,7 +397,32 @@ export function navigateToThread (loc: Location, contextId: Ref<DocNotifyContext
|
||||
loc.path[4] = _id
|
||||
loc.fragment = undefined
|
||||
loc.query = { message: _id }
|
||||
navigate(loc)
|
||||
|
||||
return loc
|
||||
}
|
||||
|
||||
export async function getThreadLink (doc: ThreadMessage): Promise<Location> {
|
||||
const loc = getCurrentResolvedLocation()
|
||||
const client = getClient()
|
||||
const inboxClient = InboxNotificationsClientImpl.getClient()
|
||||
|
||||
let contextId: Ref<DocNotifyContext> | undefined = get(inboxClient.docNotifyContextByDoc).get(doc.objectId)?._id
|
||||
|
||||
if (contextId === undefined) {
|
||||
contextId = await client.createDoc(notification.class.DocNotifyContext, doc.space, {
|
||||
attachedTo: doc.attachedTo,
|
||||
attachedToClass: doc.attachedToClass,
|
||||
user: getCurrentAccount()._id,
|
||||
hidden: false,
|
||||
lastViewedTimestamp: Date.now()
|
||||
})
|
||||
}
|
||||
|
||||
if (contextId === undefined) {
|
||||
return loc
|
||||
}
|
||||
|
||||
return buildThreadLink(loc, contextId, doc.attachedTo)
|
||||
}
|
||||
|
||||
export async function joinChannel (channel: Channel, value: Ref<Account> | Array<Ref<Account>>): Promise<void> {
|
||||
|
Loading…
Reference in New Issue
Block a user