|
|
@@ -33,6 +33,9 @@ import { useIsDeviceSmallerThanLg } from '~/stores/ui';
|
|
|
import { useSWRxPageInfo } from '../../stores/page';
|
|
|
import { ForceHideMenuItems, PageItemControl } from '../Common/Dropdown/PageItemControl';
|
|
|
import PagePathHierarchicalLink from '../PagePathHierarchicalLink';
|
|
|
+import { useCurrentUser } from '~/stores/context';
|
|
|
+import { useSWRxBookmarkFolderAndChild } from '~/stores/bookmark-folder';
|
|
|
+import { mutateSearching } from '~/stores/search';
|
|
|
|
|
|
type Props = {
|
|
|
page: IPageWithSearchMeta | IPageWithMeta<IPageInfoForListing & IPageSearchMeta>,
|
|
|
@@ -88,10 +91,13 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
|
|
|
const { open: openDeleteModal } = usePageDeleteModal();
|
|
|
const { open: openPutBackPageModal } = usePutBackPageModal();
|
|
|
|
|
|
+ const {data: currentUser } = useCurrentUser();
|
|
|
const shouldFetch = isSelected && (pageData != null || pageMeta != null);
|
|
|
const { data: pageInfo } = useSWRxPageInfo(shouldFetch ? pageData?._id : null);
|
|
|
- const { mutate: mutateUserBookmark } = useSWRxUserBookmarks();
|
|
|
+ const { mutate: mutateUserBookmark } = useSWRxUserBookmarks(currentUser?._id);
|
|
|
const { mutate: mutateBookmarkInfo } = useSWRBookmarkInfo(pageData?._id);
|
|
|
+ const { mutate: mutatePageInfo } = useSWRxPageInfo(pageData._id);
|
|
|
+ const { mutate: mutateBookmarkFolders } = useSWRxBookmarkFolderAndChild(currentUser?._id);
|
|
|
const elasticSearchResult = isIPageSearchMeta(pageMeta) ? pageMeta.elasticSearchResult : null;
|
|
|
const revisionShortBody = isIPageInfoForListing(pageMeta) ? pageMeta.revisionShortBody : null;
|
|
|
|
|
|
@@ -160,6 +166,11 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
|
|
|
try {
|
|
|
// pageData path should be `/trash/fuga` (`/trash` should be included to the prefix)
|
|
|
await unlink(pageData.path);
|
|
|
+ mutateSearching();
|
|
|
+ mutatePageInfo();
|
|
|
+ mutateUserBookmark();
|
|
|
+ mutateBookmarkInfo();
|
|
|
+ mutateBookmarkFolders();
|
|
|
}
|
|
|
catch (err) {
|
|
|
toastError(err);
|
|
|
@@ -171,7 +182,7 @@ const PageListItemLSubstance: ForwardRefRenderFunction<ISelectable, Props> = (pr
|
|
|
}
|
|
|
};
|
|
|
openPutBackPageModal({ pageId, path }, { onPutBacked: putBackedHandler });
|
|
|
- }, [onPagePutBacked, openPutBackPageModal, pageData]);
|
|
|
+ }, [onPagePutBacked, openPutBackPageModal, pageData, mutateSearching, mutatePageInfo, mutateUserBookmark, mutateBookmarkInfo, mutateBookmarkFolders]);
|
|
|
|
|
|
const styleListGroupItem = (!isDeviceSmallerThanLg && onClickItem != null) ? 'list-group-item-action' : '';
|
|
|
// background color of list item changes when class "active" exists under 'list-group-item'
|