Skip to content

Commit adb15de

Browse files
committed
♻️(frontend) reduce props drilling
- Reduce proprs drilling - Improve state rerendering with useIsCollaborativeEditable
1 parent 6ece326 commit adb15de

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

src/frontend/apps/impress/src/features/docs/doc-editor/components/DocEditor.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ export const DocEditor = ({ doc, versionId }: DocEditorProps) => {
5454
$padding={{ horizontal: isDesktop ? '54px' : 'base' }}
5555
className="--docs--doc-editor-header"
5656
>
57-
{isVersion ? (
58-
<DocVersionHeader title={doc.title} />
59-
) : (
60-
<DocHeader doc={doc} />
61-
)}
57+
{isVersion ? <DocVersionHeader /> : <DocHeader doc={doc} />}
6258
</Box>
6359

6460
<Box

src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
KEY_DOC,
1414
KEY_LIST_DOC,
1515
KEY_SUB_PAGE,
16+
useDocStore,
1617
useTrans,
1718
useUpdateDoc,
1819
} from '@/docs/doc-management';
@@ -24,18 +25,15 @@ interface DocTitleProps {
2425

2526
export const DocTitle = ({ doc }: DocTitleProps) => {
2627
if (!doc.abilities.partial_update) {
27-
return <DocTitleText title={doc.title} />;
28+
return <DocTitleText />;
2829
}
2930

3031
return <DocTitleInput doc={doc} />;
3132
};
3233

33-
interface DocTitleTextProps {
34-
title?: string;
35-
}
36-
37-
export const DocTitleText = ({ title }: DocTitleTextProps) => {
34+
export const DocTitleText = () => {
3835
const { isMobile } = useResponsiveStore();
36+
const { currentDoc } = useDocStore();
3937
const { untitledDocument } = useTrans();
4038

4139
return (
@@ -45,7 +43,7 @@ export const DocTitleText = ({ title }: DocTitleTextProps) => {
4543
$size={isMobile ? 'h4' : 'h2'}
4644
$variation="1000"
4745
>
48-
{title || untitledDocument}
46+
{currentDoc?.title || untitledDocument}
4947
</Text>
5048
);
5149
};

src/frontend/apps/impress/src/features/docs/doc-header/components/DocVersionHeader.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ import { useCunninghamTheme } from '@/cunningham';
55

66
import { DocTitleText } from './DocTitle';
77

8-
interface DocVersionHeaderProps {
9-
title?: string;
10-
}
11-
12-
export const DocVersionHeader = ({ title }: DocVersionHeaderProps) => {
8+
export const DocVersionHeader = () => {
139
const { spacingsTokens } = useCunninghamTheme();
1410

1511
const { t } = useTranslation();
@@ -23,7 +19,7 @@ export const DocVersionHeader = ({ title }: DocVersionHeaderProps) => {
2319
aria-label={t('It is the document title')}
2420
className="--docs--doc-version-header"
2521
>
26-
<DocTitleText title={title} />
22+
<DocTitleText />
2723
<HorizontalSeparator />
2824
</Box>
2925
</>

0 commit comments

Comments
 (0)