feat: add hook useBlockSuiteWorkspaceName (#1281)

This commit is contained in:
Himself65
2023-03-02 20:00:42 -06:00
committed by GitHub
parent 9d46b358d4
commit 1e2f91fe21
5 changed files with 55 additions and 10 deletions
@@ -1,5 +1,6 @@
import React from 'react';
import { useBlockSuiteWorkspaceName } from '../../../../hooks/use-blocksuite-workspace-name';
import { RemWorkspace } from '../../../../shared';
import { WorkspaceAvatar } from '../../workspace-avatar';
import { SelectorWrapper, WorkspaceName } from './styles';
@@ -13,16 +14,9 @@ export const WorkspaceSelector: React.FC<WorkspaceSelectorProps> = ({
currentWorkspace,
onClick,
}) => {
let name = 'Untitled Workspace';
if (currentWorkspace) {
if (currentWorkspace.flavour === 'affine') {
if (currentWorkspace.firstBinarySynced) {
name = currentWorkspace.blockSuiteWorkspace.meta.name;
}
} else if (currentWorkspace.flavour === 'local') {
name = currentWorkspace.blockSuiteWorkspace.meta.name;
}
}
const [name] = useBlockSuiteWorkspaceName(
currentWorkspace?.blockSuiteWorkspace ?? null
);
return (
<>
<SelectorWrapper onClick={onClick} data-testid="current-workspace">