Fix read vacancy (#3039)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-04-21 16:30:27 +06:00 committed by GitHub
parent cc5e7adb41
commit a7f3dae031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<Vacancy>
export let embedded = false
@ -33,10 +36,16 @@
let object: Required<Vacancy>
let rawName: string = ''
let rawDesc: string = ''
let lastId: Ref<Vacancy> | 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,12 +53,19 @@
const clazz = client.getHierarchy().getClass(recruit.class.Vacancy)
function updateObject (_id: Ref<Vacancy>): void {
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<Vacancy>
rawName = object.name
rawDesc = object.description
})
}
}
$: updateObject(_id)