diff --git a/webapp/src/components/workspaceComponent.tsx b/webapp/src/components/workspaceComponent.tsx index 3e0b5566c..c17036457 100644 --- a/webapp/src/components/workspaceComponent.tsx +++ b/webapp/src/components/workspaceComponent.tsx @@ -26,7 +26,7 @@ class WorkspaceComponent extends React.PureComponent { render(): JSX.Element { const {boardTree, workspaceTree, showBoard, showView, setLanguage} = this.props - Utils.assert(workspaceTree) + Utils.assert(workspaceTree || !this.props.readonly) const element = (
{!this.props.readonly && diff --git a/webapp/src/pages/boardPage.tsx b/webapp/src/pages/boardPage.tsx index c57fc52d4..893955e0b 100644 --- a/webapp/src/pages/boardPage.tsx +++ b/webapp/src/pages/boardPage.tsx @@ -202,37 +202,41 @@ class BoardPage extends React.Component { private async sync(boardId: string = this.state.boardId, viewId: string | undefined = this.state.viewId) { Utils.log(`sync start: ${boardId}`) - const workspace = await octoClient.getWorkspace() - if (!workspace) { - location.href = '/error?id=no_workspace' + if (!this.props.readonly) { + // Require workspace for editing, not for sharing (readonly) + + const workspace = await octoClient.getWorkspace() + if (!workspace) { + location.href = '/error?id=no_workspace' + } + + const workspaceTree = await MutableWorkspaceTree.sync() + const boardIds = [...workspaceTree.boards.map((o) => o.id), ...workspaceTree.boardTemplates.map((o) => o.id)] + this.setState({workspaceTree}) + + let boardIdsToListen: string[] + if (boardIds.length > 0) { + boardIdsToListen = ['', ...boardIds] + } else { + // Read-only view + boardIdsToListen = [this.state.boardId] + } + + // Listen to boards plus all blocks at root (Empty string for parentId) + this.workspaceListener.open( + octoClient.workspaceId, + boardIdsToListen, + async (blocks) => { + Utils.log(`workspaceListener.onChanged: ${blocks.length}`) + this.incrementalUpdate(blocks) + }, + () => { + Utils.log('workspaceListener.onReconnect') + this.sync() + }, + ) } - const workspaceTree = await MutableWorkspaceTree.sync() - const boardIds = [...workspaceTree.boards.map((o) => o.id), ...workspaceTree.boardTemplates.map((o) => o.id)] - this.setState({workspaceTree}) - - let boardIdsToListen: string[] - if (boardIds.length > 0) { - boardIdsToListen = ['', ...boardIds] - } else { - // Read-only view - boardIdsToListen = [this.state.boardId] - } - - // Listen to boards plus all blocks at root (Empty string for parentId) - this.workspaceListener.open( - octoClient.workspaceId, - boardIdsToListen, - async (blocks) => { - Utils.log(`workspaceListener.onChanged: ${blocks.length}`) - this.incrementalUpdate(blocks) - }, - () => { - Utils.log('workspaceListener.onReconnect') - this.sync() - }, - ) - if (boardId) { const boardTree = await MutableBoardTree.sync(boardId, viewId)