mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 22:38:56 +08:00
fix(web): setting panel refresh (#3070)
(cherry picked from commit 28653d6892)
This commit is contained in:
@@ -113,6 +113,7 @@ export const LocalAdapter: WorkspaceAdapter<WorkspaceFlavour.LOCAL> = {
|
|||||||
<NewWorkspaceSettingDetail
|
<NewWorkspaceSettingDetail
|
||||||
onDeleteWorkspace={onDeleteWorkspace}
|
onDeleteWorkspace={onDeleteWorkspace}
|
||||||
workspace={currentWorkspace}
|
workspace={currentWorkspace}
|
||||||
|
key={currentWorkspace.id}
|
||||||
onTransferWorkspace={onTransformWorkspace}
|
onTransferWorkspace={onTransformWorkspace}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
|||||||
import { DoneIcon } from '@blocksuite/icons';
|
import { DoneIcon } from '@blocksuite/icons';
|
||||||
import { useBlockSuiteWorkspaceAvatarUrl } from '@toeverything/hooks/use-block-suite-workspace-avatar-url';
|
import { useBlockSuiteWorkspaceAvatarUrl } from '@toeverything/hooks/use-block-suite-workspace-avatar-url';
|
||||||
import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name';
|
import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name';
|
||||||
import { type FC, useCallback, useRef, useState } from 'react';
|
import { type FC, useCallback, useState } from 'react';
|
||||||
|
|
||||||
import type { AffineOfficialWorkspace } from '../../../shared';
|
import type { AffineOfficialWorkspace } from '../../../shared';
|
||||||
import { Upload } from '../../pure/file-upload';
|
import { Upload } from '../../pure/file-upload';
|
||||||
@@ -38,16 +38,12 @@ export const ProfilePanel: FC<{
|
|||||||
workspace.blockSuiteWorkspace
|
workspace.blockSuiteWorkspace
|
||||||
);
|
);
|
||||||
|
|
||||||
const [prevName, setPrevName] = useState(
|
|
||||||
workspace.blockSuiteWorkspace.meta.name
|
|
||||||
);
|
|
||||||
const [name, setName] = useBlockSuiteWorkspaceName(
|
const [name, setName] = useBlockSuiteWorkspaceName(
|
||||||
workspace.blockSuiteWorkspace
|
workspace.blockSuiteWorkspace
|
||||||
);
|
);
|
||||||
|
|
||||||
const [input, setInput] = useState<string>(name);
|
const [input, setInput] = useState<string>(name);
|
||||||
|
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
|
||||||
const handleUpdateWorkspaceName = useCallback(
|
const handleUpdateWorkspaceName = useCallback(
|
||||||
(name: string) => {
|
(name: string) => {
|
||||||
setName(name);
|
setName(name);
|
||||||
@@ -56,13 +52,6 @@ export const ProfilePanel: FC<{
|
|||||||
[setName, t]
|
[setName, t]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (prevName !== name) {
|
|
||||||
setPrevName(name);
|
|
||||||
if (inputRef.current) {
|
|
||||||
inputRef.current.value = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.profileWrapper}>
|
<div className={style.profileWrapper}>
|
||||||
<div className={style.avatarWrapper}>
|
<div className={style.avatarWrapper}>
|
||||||
@@ -81,7 +70,6 @@ export const ProfilePanel: FC<{
|
|||||||
</div>
|
</div>
|
||||||
<div className={style.profileHandlerWrapper}>
|
<div className={style.profileHandlerWrapper}>
|
||||||
<Input
|
<Input
|
||||||
ref={inputRef}
|
|
||||||
width={280}
|
width={280}
|
||||||
height={32}
|
height={32}
|
||||||
defaultValue={input}
|
defaultValue={input}
|
||||||
|
|||||||
Reference in New Issue
Block a user