Просмотр исходного кода

Fix prop types and remove null checking

Mudana-Grune 3 лет назад
Родитель
Сommit
0aae3aecd8

+ 8 - 10
packages/app/src/components/PageHistory/Revision.tsx

@@ -1,6 +1,6 @@
 import React from 'react';
 
-import { IRevisionHasId, Nullable, pathUtils } from '@growi/core';
+import { IRevisionHasId, pathUtils } from '@growi/core';
 import { UserPicture } from '@growi/ui';
 import { useTranslation } from 'next-i18next';
 import Link from 'next/link';
@@ -15,8 +15,8 @@ type RevisionProps = {
   revision: IRevisionHasId,
   isLatestRevision: boolean,
   hasDiff: boolean,
-  currentPageId: Nullable<string> | undefined,
-  currentPagePath: Nullable<string> | undefined,
+  currentPageId: string
+  currentPagePath: string
   onClose: () => void,
 }
 
@@ -69,13 +69,11 @@ export const Revision = (props: RevisionProps): JSX.Element => {
           <div className="mb-1">
             <UserDate dateTime={revision.createdAt} />
             <br className="d-xl-none d-block" />
-            {currentPagePath && currentPageId && (
-              <Link href={urljoin(returnPathForURL(currentPagePath, currentPageId), `?revisionId=${revision._id}`)} prefetch={false}>
-                <a className="ml-xl-3" onClick={onClose}>
-                  <i className="icon-login"></i> {t('Go to this version')}
-                </a>
-              </Link>
-            )}
+            <Link href={urljoin(returnPathForURL(currentPagePath, currentPageId), `?revisionId=${revision._id}`)} prefetch={false}>
+              <a className="ml-xl-3" onClick={onClose}>
+                <i className="icon-login"></i> {t('Go to this version')}
+              </a>
+            </Link>
           </div>
         </div>
       </div>

+ 1 - 1
packages/app/src/components/RevisionComparer/RevisionComparer.tsx

@@ -1,6 +1,6 @@
 import React, { useState } from 'react';
 
-import { IRevisionHasPageId, Nullable, pagePathUtils } from '@growi/core';
+import { IRevisionHasPageId, pagePathUtils } from '@growi/core';
 import { useTranslation } from 'next-i18next';
 import { CopyToClipboard } from 'react-copy-to-clipboard';
 import {

+ 1 - 1
packages/app/src/stores/page.tsx

@@ -154,7 +154,7 @@ type SWRInfinitePageRevisionsResponse = {
 }
 
 export const useSWRxInfinitePageRevisions = (
-    pageId: string | null | undefined,
+    pageId: string,
     limit: number,
 ): SWRInfiniteResponse<SWRInfinitePageRevisionsResponse, Error> => {
   return useSWRInfinite(