|
@@ -20,11 +20,12 @@ import { MenuItemType, PageItemControl } from '../Common/Dropdown/PageItemContro
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
|
bookmarkedPage: IPageHasId,
|
|
bookmarkedPage: IPageHasId,
|
|
|
- onPageOperationSuccess: () => void
|
|
|
|
|
|
|
+ onUnbookmarked: () => void,
|
|
|
|
|
+ onRenamed: () => void
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const BookmarkItem = (props: Props) => {
|
|
const BookmarkItem = (props: Props) => {
|
|
|
- const { bookmarkedPage, onPageOperationSuccess } = props;
|
|
|
|
|
|
|
+ const { bookmarkedPage, onUnbookmarked, onRenamed } = props;
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
const [isRenameInputShown, setRenameInputShown] = useState(false);
|
|
const [isRenameInputShown, setRenameInputShown] = useState(false);
|
|
|
const dPagePath = new DevidedPagePath(bookmarkedPage.path, false, true);
|
|
const dPagePath = new DevidedPagePath(bookmarkedPage.path, false, true);
|
|
@@ -34,8 +35,8 @@ const BookmarkItem = (props: Props) => {
|
|
|
|
|
|
|
|
const bookmarkMenuItemClickHandler = useCallback(async() => {
|
|
const bookmarkMenuItemClickHandler = useCallback(async() => {
|
|
|
await unbookmark(bookmarkedPage._id);
|
|
await unbookmark(bookmarkedPage._id);
|
|
|
- onPageOperationSuccess();
|
|
|
|
|
- }, [onPageOperationSuccess, bookmarkedPage]);
|
|
|
|
|
|
|
+ onUnbookmarked();
|
|
|
|
|
+ }, [onUnbookmarked, bookmarkedPage]);
|
|
|
|
|
|
|
|
const renameMenuItemClickHandler = useCallback(() => {
|
|
const renameMenuItemClickHandler = useCallback(() => {
|
|
|
setRenameInputShown(true);
|
|
setRenameInputShown(true);
|
|
@@ -67,14 +68,14 @@ const BookmarkItem = (props: Props) => {
|
|
|
revisionId: bookmarkedPage.revision,
|
|
revisionId: bookmarkedPage.revision,
|
|
|
newPagePath,
|
|
newPagePath,
|
|
|
});
|
|
});
|
|
|
- onPageOperationSuccess();
|
|
|
|
|
|
|
+ onRenamed();
|
|
|
toastSuccess(t('renamed_pages', { path: bookmarkedPage.path }));
|
|
toastSuccess(t('renamed_pages', { path: bookmarkedPage.path }));
|
|
|
}
|
|
}
|
|
|
catch (err) {
|
|
catch (err) {
|
|
|
setRenameInputShown(true);
|
|
setRenameInputShown(true);
|
|
|
toastError(err);
|
|
toastError(err);
|
|
|
}
|
|
}
|
|
|
- }, [bookmarkedPage, onPageOperationSuccess, t]);
|
|
|
|
|
|
|
+ }, [bookmarkedPage, onRenamed, t]);
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className="d-flex justify-content-between" key={bookmarkedPage._id}>
|
|
<div className="d-flex justify-content-between" key={bookmarkedPage._id}>
|
|
@@ -135,7 +136,12 @@ const Bookmarks = () : JSX.Element => {
|
|
|
<div className="grw-bookmarks-item-container">
|
|
<div className="grw-bookmarks-item-container">
|
|
|
{ currentUserBookmarksData?.map((currentUserBookmark) => {
|
|
{ currentUserBookmarksData?.map((currentUserBookmark) => {
|
|
|
return (
|
|
return (
|
|
|
- <BookmarkItem key={currentUserBookmark._id} bookmarkedPage={currentUserBookmark} onPageOperationSuccess={mutateCurrentUserBookmarks} />
|
|
|
|
|
|
|
+ <BookmarkItem
|
|
|
|
|
+ key={currentUserBookmark._id}
|
|
|
|
|
+ bookmarkedPage={currentUserBookmark}
|
|
|
|
|
+ onUnbookmarked={mutateCurrentUserBookmarks}
|
|
|
|
|
+ onRenamed={mutateCurrentUserBookmarks}
|
|
|
|
|
+ />
|
|
|
);
|
|
);
|
|
|
})}
|
|
})}
|
|
|
</div>
|
|
</div>
|