fix: deepscan error (#733)

This commit is contained in:
zuomeng wang
2023-01-13 15:54:21 +08:00
committed by GitHub
parent ba9a57d4ae
commit 21d24ad542
4 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ export const Editor = ({ page, workspace, setEditor }: Props) => {
}
setEditor(editor);
document.title = page?.meta.title || 'Untitled';
document.title = page.meta.title || 'Untitled';
return ret;
}, [workspace, page, setEditor]);
@@ -25,7 +25,7 @@ const Page: NextPageWithLayout = () => {
p => p.id === router.query.pageId
)
) {
const page = data.blocksuiteWorkspace?.getPage(
const page = data.blocksuiteWorkspace.getPage(
router.query.pageId as string
);
page && setPage(page);
@@ -101,14 +101,15 @@ export const AppStateProvider = ({
}
const workspace = (await dataCenter.loadWorkspace(workspaceId)) ?? null;
let isOwner;
if (workspace.provider === 'local') {
if (workspace?.provider === 'local') {
// isOwner is useful only in the cloud
isOwner = true;
} else {
isOwner = workspace.owner && user?.id === workspace.owner.id;
// We must ensure workspace.owner exists, then ensure id same.
isOwner = workspace?.owner && user?.id === workspace.owner.id;
}
const pageList =
(workspace.blocksuiteWorkspace?.meta.pageMetas as PageMeta[]) ?? [];
(workspace?.blocksuiteWorkspace?.meta.pageMetas as PageMeta[]) ?? [];
setAppState({
...appState,
currentWorkspace: workspace,
+3 -1
View File
@@ -150,7 +150,9 @@ export class DataCenter {
* @param {string} workspaceId workspace id
* @returns {Promise<WorkspaceUnit>}
*/
public async loadWorkspace(workspaceId: string) {
public async loadWorkspace(
workspaceId: string
): Promise<WorkspaceUnit | null> {
const workspaceUnit = this._workspaceUnitCollection.find(workspaceId);
assert(workspaceUnit, 'Workspace not found');
const currentProvider = this.providerMap.get(workspaceUnit.provider);