Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: The user's bookmarks are updated by unrelated user's operation #7670

Merged
merged 1 commit into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions apps/app/src/components/Bookmarks/BookmarkFolderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ export const BookmarkFolderMenu: React.FC<{children?: React.ReactNode}> = ({ chi
setSelectedItem(itemId);

try {
if (isBookmarked) {
await toggleBookmarkHandler();
}
Comment on lines -91 to -93
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この呼び出しは不要

if (currentPage != null) {
await addBookmarkToFolder(currentPage._id, itemId === 'root' ? null : itemId);
}
Expand All @@ -101,7 +98,7 @@ export const BookmarkFolderMenu: React.FC<{children?: React.ReactNode}> = ({ chi
catch (err) {
toastError(err);
}
}, [mutateBookmarkFolders, isBookmarked, currentPage, mutateBookmarkInfo, mutateUserBookmarks, toggleBookmarkHandler]);
}, [mutateBookmarkFolders, currentPage, mutateBookmarkInfo, mutateUserBookmarks]);

const renderBookmarkMenuItem = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/server/models/bookmark-folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ bookmarkFolderSchema.statics.updateBookmark = async function(pageId: Types.Objec
Promise<BookmarkFolderDocument | null> {
// If isBookmarked
if (status) {
const bookmarkedPage = await Bookmark.findOne({ page: pageId });
const bookmarkedPage = await Bookmark.findOne({ page: pageId, user: userId });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user も見るように修正

const bookmarkFolder = await this.findOne({ owner: userId, bookmarks: { $in: [bookmarkedPage?._id] } });
if (bookmarkFolder != null) {
await this.updateOne({ owner: userId, _id: bookmarkFolder._id }, { $pull: { bookmarks: bookmarkedPage?._id } });
Expand Down