import core, { Class, Client, Doc, DocIndexState, Ref } from '@hcengineering/core' import { writable } from 'svelte/store' export interface InferenceFocus { objectId: Ref objectClass: Ref> state: DocIndexState } /** * @public */ export const inferenceFocusStore = writable(undefined) /** * @public */ export async function updateFocus (client: Client, doc?: { _id: Ref, _class: Ref> }): Promise { if (doc === undefined) { inferenceFocusStore.set(undefined) return } const state = await client.findOne(core.class.DocIndexState, { _id: doc._id as Ref, objectClass: doc._class }) if (state !== undefined) { inferenceFocusStore.update(() => { return { objectId: doc._id, objectClass: doc._class, state } }) } }