UBERF-4707: fix activity messages updating (#4238)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina
2023-12-21 22:31:32 +07:00
committed by GitHub
parent 93551a71b0
commit ba49e4d66e
16 changed files with 237 additions and 129 deletions
@@ -13,15 +13,13 @@
// limitations under the License.
-->
<script lang="ts">
import { DocNavLink, getDocLinkTitle } from '@hcengineering/view-resources'
import { buildRemovedDoc, checkIsObjectRemoved, DocNavLink, getDocLinkTitle } from '@hcengineering/view-resources'
import { Component, Icon, IconAdd, IconDelete } from '@hcengineering/ui'
import { getClient } from '@hcengineering/presentation'
import { createQuery, getClient } from '@hcengineering/presentation'
import view, { ObjectPanel, ObjectPresenter } from '@hcengineering/view'
import { Doc } from '@hcengineering/core'
import { Class, Doc, Ref } from '@hcengineering/core'
import { DisplayDocUpdateMessage, DocUpdateMessageViewlet } from '@hcengineering/activity'
import { getActivityObject } from '../../activityMessagesUtils'
export let message: DisplayDocUpdateMessage
export let viewlet: DocUpdateMessageViewlet | undefined
export let objectPanel: ObjectPanel | undefined
@@ -30,6 +28,9 @@
export let hasSeparator: boolean = false
const client = getClient()
const objectQuery = createQuery()
let object: Doc | undefined = undefined
async function getValue (object: Doc | undefined): Promise<string | undefined> {
if (object === undefined) {
@@ -42,9 +43,23 @@
return await getDocLinkTitle(client, object._id, object._class, object)
}
async function loadObject (_id: Ref<Doc>, _class: Ref<Class<Doc>>) {
const isRemoved = await checkIsObjectRemoved(client, _id, _class)
if (isRemoved) {
object = await buildRemovedDoc(client, _id, _class)
} else {
objectQuery.query(_class, { _id }, (res) => {
object = res[0]
})
}
}
$: loadObject(message.objectId, message.objectClass)
</script>
{#await getActivityObject(client, message.objectId, message.objectClass) then { object }}
{#if object}
{#await getValue(object) then value}
{#if withIcon && message.action === 'create'}
<Icon icon={IconAdd} size="x-small" />
@@ -71,7 +86,7 @@
<Component is={objectPresenter.presenter} props={{ value: object, accent: true, shouldShowAvatar: false }} />
{/if}
{/await}
{/await}
{/if}
<style lang="scss">
.valueLink {