Преглед изворни кода

restrict count badge props to only number

yuken пре 4 година
родитељ
комит
45783e737d

+ 1 - 1
packages/app/src/components/Common/CountBadge.tsx

@@ -1,7 +1,7 @@
 import React, { FC } from 'react';
 import React, { FC } from 'react';
 
 
 type CountProps = {
 type CountProps = {
-  count: number | null | undefined
+  count: number
 }
 }
 
 
 const CountBadge: FC<CountProps> = (props:CountProps) => {
 const CountBadge: FC<CountProps> = (props:CountProps) => {

+ 2 - 2
packages/app/src/components/Page/DisplaySwitcher.tsx

@@ -78,7 +78,7 @@ const DisplaySwitcher = (): JSX.Element => {
                           <PageListIcon />
                           <PageListIcon />
                         </div>
                         </div>
                         {t('page_list')}
                         {t('page_list')}
-                        <CountBadge count={pagingResult?.totalCount} />
+                        {pagingResult != null && <CountBadge count={pagingResult.totalCount} />}
                       </button>
                       </button>
                     ) }
                     ) }
                   </div>
                   </div>
@@ -93,7 +93,7 @@ const DisplaySwitcher = (): JSX.Element => {
                       >
                       >
                         <i className="icon-fw icon-bubbles grw-page-accessories-control-icon"></i>
                         <i className="icon-fw icon-bubbles grw-page-accessories-control-icon"></i>
                         <span>Comments</span>
                         <span>Comments</span>
-                        <CountBadge count={comments != null ? comments.length : 0} />
+                        {comments != null && <CountBadge count={comments.length} />}
                       </button>
                       </button>
                     </div>
                     </div>
                   ) }
                   ) }