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>
@ -63,7 +64,7 @@ Start to play with <a href="https://affine.pro"><b>AFFiNE web version</b></a> on
/>
</a></p>
If you have experience in front-end development, you may wish to refer to our [documentation](https://docs.affine.pro/affine/basic-documentation/contribute-to-affine) to learn more about deploying your own version or contributing further to development.
If you have experience in front-end development, you may wish to refer to our [documentation](https://docs.affine.pro/affine/basic-documentation/contribute-to-affine) to learn more about deploying your own version or contributing further to development.
Also, thanks to Lee who has made a [desktop build with Tauri](https://github.com/m1911star/affine-client) for you to try out.
Please notice that AFFiNE is still under Alpha stage and is not ready for production use.

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