There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat: add updateWorkspace function
DiamondThree84b62e474afe
diff --git a/packages/app/src/components/workspace-setting/general/General.tsx b/packages/app/src/components/workspace-setting/general/General.tsxindex dd342d79a4..a424685e97 100644--- a/packages/app/src/components/workspace-setting/general/General.tsx+++ b/packages/app/src/components/workspace-setting/general/General.tsx@@ -15,11 +15,14 @@ import { WorkspaceLeave } from './leave';import { Upload } from '@/components/file-upload';import { WorkspaceAvatar } from '@/components/workspace-avatar';import { WorkspaceInfo } from '@affine/datacenter';+import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';export const GeneralPage = ({ workspace }: { workspace: WorkspaceInfo }) => {const [showDelete, setShowDelete] = useState<boolean>(false);const [showLeave, setShowLeave] = useState<boolean>(false);const [uploading, setUploading] = useState<boolean>(false);const [workspaceName, setWorkspaceName] = useState<string>(workspace.name);+ const { currentWorkspace } = useAppState();+ const { updateWorkspace } = useWorkspaceHelper();const isOwner = true;const handleChangeWorkSpaceName = (newName: string) => {setWorkspaceName(newName);@@ -38,6 +41,8 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceInfo }) => {setShowLeave(false);};const handleUpdateWorkspaceName = () => {+ console.log('currentWorkspace: ', currentWorkspace);+ updateWorkspace({ name: workspaceName }, currentWorkspace);// workspace && currentWorkspace(workspace.id, { name: workspaceName });};@@ -97,22 +102,6 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceInfo }) => {✔️</TextButton></StyledSettingInputContainer>- {/* {userInfo ? (- <div>- <StyledSettingH2 marginTop={20}>Workspace Owner</StyledSettingH2>- <StyledSettingInputContainer>- <Input- width={327}- disabled- value={userInfo?.name}- placeholder="Workspace Owner"- ></Input>- </StyledSettingInputContainer>- </div>- ) : (- ''- )} */}-<StyledSettingH2 marginTop={20}>Workspace Type</StyledSettingH2><StyledSettingInputContainer><code>{workspace.provider} </code>diff --git a/packages/app/src/hooks/use-workspace-helper.ts b/packages/app/src/hooks/use-workspace-helper.tsindex 4a396074d4..5b49a8b1e5 100644--- a/packages/app/src/hooks/use-workspace-helper.ts+++ b/packages/app/src/hooks/use-workspace-helper.ts@@ -1,6 +1,7 @@import { useAppState } from '@/providers/app-state-provider';+import { stringToColour } from '@/utils';import { WorkspaceInfo } from '@affine/datacenter';-+import { Workspace } from '@blocksuite/store';export const useWorkspaceHelper = () => {const { dataCenter } = useAppState();const createWorkspace = async (name: string) => {@@ -21,8 +22,16 @@ export const useWorkspaceHelper = () => {dataCenter.setWorkspacePublish(workspaceId, publish);};- const updateWorkspace = async (workspace: WorkspaceInfo) => {- console.log('workspace: ', workspace);+ const updateWorkspace = async (+ { name, avatar }: { name?: string; avatar?: string },+ workspace: Workspace+ ) => {+ if (name) {+ dataCenter.resetWorkspaceMeta({ name }, workspace);+ }+ // if (avatar) {+ // dataCenter.resetWorkspaceMeta({ avatar }, workspace);+ // }};return {createWorkspace,