فهرست منبع

Remove swr from props

https://youtrack.weseek.co.jp/issue/GW-7841
- Remove swr props from BookmarksItem
- Implement openDeleteModal
- Implement refreshBookmarkList after delete a page from bookmarks
Mudana-Grune 3 سال پیش
والد
کامیت
73fefb6003
1فایلهای تغییر یافته به همراه6 افزوده شده و 8 حذف شده
  1. 6 8
      packages/app/src/components/Sidebar/Bookmarks.tsx

+ 6 - 8
packages/app/src/components/Sidebar/Bookmarks.tsx

@@ -1,20 +1,19 @@
 
-import React, {
-  FC, useCallback, useEffect, useState,
-} from 'react';
+import React, { useCallback, useEffect, useState } from 'react';
 
 import nodePath from 'path';
 
 import { DevidedPagePath, pathUtils } from '@growi/core';
 import { useTranslation } from 'react-i18next';
 import { UncontrolledTooltip, DropdownToggle } from 'reactstrap';
+
 import { unbookmark } from '~/client/services/page-operation';
 import { toastError, toastSuccess } from '~/client/util/apiNotification';
+import { apiv3Get, apiv3Put } from '~/client/util/apiv3-client';
 import { IPageHasId, IPageInfoAll, IPageToDeleteWithMeta } from '~/interfaces/page';
 import { OnDeletedFunction } from '~/interfaces/ui';
-import { usePageDeleteModal } from '~/stores/modal';
-import { apiv3Get, apiv3Put } from '~/client/util/apiv3-client';
 import { useCurrentUser, useIsGuestUser } from '~/stores/context';
+import { usePageDeleteModal } from '~/stores/modal';
 import loggerFactory from '~/utils/logger';
 
 import ClosableTextInput, { AlertInfo, AlertType } from '../Common/ClosableTextInput';
@@ -36,7 +35,7 @@ const BookmarksItem = (props: Props) => {
   const dPagePath = new DevidedPagePath(page.path, false, true);
   const { latter: pageTitle, former: formerPagePath } = dPagePath;
   const bookmarkItemId = `bookmark-item-${page._id}`;
-
+  const { open: openDeleteModal } = usePageDeleteModal();
 
   const bookmarkMenuItemClickHandler = useCallback(async() => {
     await unbookmark(page._id);
@@ -82,7 +81,6 @@ const BookmarksItem = (props: Props) => {
     }
   });
 
-
   const deleteMenuItemClickHandler = useCallback(async(_pageId: string, pageInfo: IPageInfoAll | undefined): Promise<void> => {
     const onClickDeleteMenuItem = (pageToDelete: IPageToDeleteWithMeta) => {
       const onDeletedHandler: OnDeletedFunction = (pathOrPathsToDelete, _isRecursively, isCompletely) => {
@@ -116,7 +114,7 @@ const BookmarksItem = (props: Props) => {
     };
 
     onClickDeleteMenuItem(pageToDelete);
-  }, [page, openDeleteModal, t]);
+  }, [page, openDeleteModal, refreshBookmarkList, t]);
 
   return (
     <>