chore: workspace name

This commit is contained in:
DarkSky 2022-08-12 19:29:33 +08:00
parent 8358c66702
commit 8b239cd292
4 changed files with 7 additions and 22 deletions

View File

@ -47,6 +47,7 @@ See https://github.com/all-?/all-contributors/issues/361#issuecomment-637166066
![952cd7a5-70fe-48ab-b74f-23981d94d2c5](https://user-images.githubusercontent.com/79301703/182365526-df074c64-cee4-45f6-b8e0-b912f17332c6.gif)
# How to use
<h3 align="center">
🥳🥳🥳 Our web live demo is ready! 🥳🥳🥳
</h3>

View File

@ -92,18 +92,16 @@ export const WorkspaceName = () => {
const { fixedDisplay, toggleSpaceSidebar } = useShowSpaceSidebar();
const [inRename, setInRename] = useState(false);
const [workspaceName, setWorkspaceName] = useState('');
const [workspaceId, setWorkspaceId] = useState('');
const fetchWorkspaceName = useCallback(async () => {
if (!currentSpaceId) {
return;
}
const [name, workspaceId] = await Promise.all([
services.api.userConfig.getWorkspaceName(currentSpaceId),
services.api.userConfig.getWorkspaceId(currentSpaceId),
]);
const name = await services.api.userConfig.getWorkspaceName(
currentSpaceId
);
setWorkspaceName(name);
setWorkspaceId(workspaceId);
}, [currentSpaceId]);
useEffect(() => {
@ -180,7 +178,7 @@ export const WorkspaceName = () => {
) : (
<WorkspaceNameContainer>
<span onClick={() => setInRename(true)}>
{workspaceName || workspaceId}
{workspaceName || currentSpaceId}
</span>
</WorkspaceNameContainer>
)}

View File

@ -114,11 +114,6 @@ export class UserConfig extends ServiceBaseClass {
return workspaceName;
}
async getWorkspaceId(workspace: string): Promise<string> {
const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace);
return workspaceDbBlock.id;
}
async setWorkspaceName(workspace: string, workspaceName: string) {
const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace);
workspaceDbBlock.setDecoration(WORKSPACE_CONFIG, workspaceName);

View File

@ -5,15 +5,6 @@ export function getUserDisplayName(user?: UserInfo) {
return nickname || username || email || 'Unknown User';
}
/**
* Get workspace_id from URL
* @returns workspace_id
*/
export function getWorkspaceId() {
const path = window.location.pathname.match(/\/(\w+)\//);
return path ? path[1] : undefined;
}
/**
* Get page_id from URL
* @returns page_id