From 12a241eee715a6c3a70028a18fb317598602db5b Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Wed, 15 Feb 2023 10:38:48 +0600 Subject: [PATCH] Files draft fix (#2638) Signed-off-by: Denis Bykhov --- packages/presentation/src/drafts.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/presentation/src/drafts.ts b/packages/presentation/src/drafts.ts index e4d3bf27d3..9ac21eaf2c 100644 --- a/packages/presentation/src/drafts.ts +++ b/packages/presentation/src/drafts.ts @@ -1,6 +1,6 @@ +import { getCurrentAccount } from '@hcengineering/core' import { fetchMetadataLocalStorage, setMetadataLocalStorage } from '@hcengineering/ui' -import { writable, get } from 'svelte/store' -import { getClient } from '.' +import { get, writable } from 'svelte/store' import presentation from './plugin' /** @@ -14,7 +14,7 @@ export const draftStore = writable>(fetchMetadataLocalStorag */ export function updateDraftStore (id: string, draft: any): void { draftStore.update((drafts) => { - if (draft === undefined) { + if (draft !== undefined) { drafts[id] = draft } else { // eslint-disable-next-line @typescript-eslint/no-dynamic-delete @@ -29,12 +29,12 @@ export function updateDraftStore (id: string, draft: any): void { * @public */ export function updateUserDraft (id: string, draft: any): void { - const client = getClient() + const me = getCurrentAccount()._id draftStore.update((drafts) => { // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - const userDrafts: Record = drafts[client.user] || {} + const userDrafts: Record = drafts[me] || {} userDrafts[id] = draft - drafts[client.user] = userDrafts + drafts[me] = userDrafts setMetadataLocalStorage(presentation.metadata.Draft, drafts) return drafts }) @@ -44,10 +44,10 @@ export function updateUserDraft (id: string, draft: any): void { * @public */ export function getUserDraft (id: string): any { - const client = getClient() + const me = getCurrentAccount()._id const drafts: Record = get(draftStore) // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - const userDrafts: Record = drafts[client.user] || {} + const userDrafts: Record = drafts[me] || {} const draft: Record = userDrafts[id] return draft } @@ -56,9 +56,9 @@ export function getUserDraft (id: string): any { * @public */ export function isUserDraftExists (id: string): boolean { - const client = getClient() + const me = getCurrentAccount()._id const drafts: Record = get(draftStore) - const userDrafts: Record = drafts[client.user] + const userDrafts: Record = drafts[me] // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (!userDrafts) { return false