From 6ce877bd941ee8d85d3e77cde4670779e4e5a23a Mon Sep 17 00:00:00 2001 From: Himself65 Date: Mon, 20 Feb 2023 02:53:21 -0600 Subject: [PATCH] fix: remove duplicated nullish coalescing (#1132) --- packages/store/src/app/datacenter/index.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/store/src/app/datacenter/index.tsx b/packages/store/src/app/datacenter/index.tsx index 9f0a72caf..2e0ef73d1 100644 --- a/packages/store/src/app/datacenter/index.tsx +++ b/packages/store/src/app/datacenter/index.tsx @@ -75,7 +75,11 @@ export const createDataCenterActions: GlobalActionsCreator< if (workspaceId === currentDataCenterWorkspace?.id) { return currentDataCenterWorkspace; } - const workspace = (await dataCenter.loadWorkspace(workspaceId)) ?? null; + const workspace = await dataCenter.loadWorkspace(workspaceId); + + if (!workspace) { + return null; + } if (signal?.aborted) { // do not update state if aborted @@ -83,17 +87,17 @@ export const createDataCenterActions: GlobalActionsCreator< } let isOwner; - if (workspace?.provider === 'local') { + if (workspace.provider === 'local') { // isOwner is useful only in the cloud isOwner = true; } else { const userInfo = get().user; // We must ensure workspace.owner exists, then ensure id same. - isOwner = userInfo?.id === workspace?.owner?.id; + isOwner = userInfo?.id === workspace.owner?.id; } const pageList = - (workspace?.blocksuiteWorkspace?.meta.pageMetas as PageMeta[]) ?? []; - if (workspace?.blocksuiteWorkspace) { + (workspace.blocksuiteWorkspace?.meta.pageMetas as PageMeta[]) ?? []; + if (workspace.blocksuiteWorkspace) { set({ currentWorkspace: workspace.blocksuiteWorkspace, });