From a7f3dae031c3f258c9e5fc8a33a3328cf7d4444d Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Fri, 21 Apr 2023 16:30:27 +0600 Subject: [PATCH] Fix read vacancy (#3039) Signed-off-by: Denis Bykhov --- .../src/components/EditVacancy.svelte | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/plugins/recruit-resources/src/components/EditVacancy.svelte b/plugins/recruit-resources/src/components/EditVacancy.svelte index 7e183fd462..79fa6a6c35 100644 --- a/plugins/recruit-resources/src/components/EditVacancy.svelte +++ b/plugins/recruit-resources/src/components/EditVacancy.svelte @@ -26,6 +26,9 @@ import { createEventDispatcher } from 'svelte' import recruit from '../plugin' import VacancyApplications from './VacancyApplications.svelte' + import { getResource } from '@hcengineering/platform' + import notification from '@hcengineering/notification' + import { onDestroy } from 'svelte' export let _id: Ref export let embedded = false @@ -33,10 +36,16 @@ let object: Required let rawName: string = '' let rawDesc: string = '' + let lastId: Ref | undefined = undefined let showAllMixins = false const dispatch = createEventDispatcher() + const notificationClient = getResource(notification.function.GetNotificationClient).then((res) => res()) + + onDestroy(async () => { + notificationClient.then((client) => client.updateLastView(_id, recruit.class.Vacancy)) + }) const client = getClient() @@ -44,11 +53,18 @@ const clazz = client.getHierarchy().getClass(recruit.class.Vacancy) function updateObject (_id: Ref): void { - query.query(recruit.class.Vacancy, { _id }, (result) => { - object = result[0] as Required - rawName = object.name - rawDesc = object.description - }) + if (lastId !== _id) { + const prev = lastId + lastId = _id + if (prev) { + notificationClient.then((client) => client.updateLastView(prev, recruit.class.Vacancy)) + } + query.query(recruit.class.Vacancy, { _id }, (result) => { + object = result[0] as Required + rawName = object.name + rawDesc = object.description + }) + } } $: updateObject(_id)