Skip to content

Commit 9e7b08d

Browse files
committed
fix: use type guard for pageInfo in PageSideContents component
1 parent 73f475f commit 9e7b08d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

apps/app/src/client/components/PageSideContents/PageSideContents.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import React, {
55
type JSX,
66
} from 'react';
77

8-
import type { IPagePopulatedToShowRevision, IPageInfoForOperation } from '@growi/core';
8+
import type { IPagePopulatedToShowRevision } from '@growi/core';
9+
import { isIPageInfoForOperation } from '@growi/core/dist/interfaces';
910
import { pagePathUtils } from '@growi/core/dist/utils';
1011
import { useAtomValue } from 'jotai';
1112
import { useTranslation } from 'next-i18next';
@@ -129,7 +130,7 @@ export const PageSideContents = (props: PageSideContentsProps): JSX.Element => {
129130
icon={<span className="material-symbols-outlined">subject</span>}
130131
label={t('page_list')}
131132
// Do not display CountBadge if '/trash/*': https://github.com/growilabs/growi/pull/7600
132-
count={!isTrash && pageInfo != null ? (pageInfo as IPageInfoForOperation).descendantCount : undefined}
133+
count={!isTrash && isIPageInfoForOperation(pageInfo) ? pageInfo.descendantCount : undefined}
133134
offset={1}
134135
onClick={() => openDescendantPageListModal(pagePath)}
135136
/>
@@ -142,7 +143,7 @@ export const PageSideContents = (props: PageSideContentsProps): JSX.Element => {
142143
<PageAccessoriesControl
143144
icon={<span className="material-symbols-outlined">chat</span>}
144145
label={t('comments')}
145-
count={pageInfo != null ? (pageInfo as IPageInfoForOperation).commentCount : undefined}
146+
count={isIPageInfoForOperation(pageInfo) ? pageInfo.commentCount : undefined}
146147
onClick={() => scroller.scrollTo('comments-container', { smooth: false, offset: -120 })}
147148
/>
148149
</div>

0 commit comments

Comments
 (0)