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: Reverted descendant pages do not appear in search results #7587

Merged
Show file tree
Hide file tree
Changes from 4 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
11 changes: 5 additions & 6 deletions apps/app/src/server/service/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1501,8 +1501,7 @@ class PageService {
throw err;
}
}
this.pageEvent.emit('delete', page, user);
this.pageEvent.emit('create', deletedPage, user);
this.pageEvent.emit('delete', page, deletedPage, user);

return deletedPage;
}
Expand Down Expand Up @@ -1558,8 +1557,7 @@ class PageService {
}
}

this.pageEvent.emit('delete', page, user);
this.pageEvent.emit('create', deletedPage, user);
this.pageEvent.emit('delete', page, deletedPage, user);

return deletedPage;
}
Expand Down Expand Up @@ -2063,7 +2061,7 @@ class PageService {

await PageTagRelation.updateMany({ relatedPage: page._id }, { $set: { isPageTrashed: false } });

this.pageEvent.emit('revert', page, user);
this.pageEvent.emit('revert', page, updatedPage, user);

if (!isRecursively) {
await this.updateDescendantCountOfAncestors(parent._id, 1, true);
Expand Down Expand Up @@ -2092,6 +2090,7 @@ class PageService {
(async() => {
try {
await this.revertRecursivelyMainOperation(page, user, options, pageOp._id, activity);
this.pageEvent.emit('syncDescendantsUpdate', updatedPage, user);
}
catch (err) {
logger.error('Error occurred while running revertRecursivelyMainOperation.', err);
Expand Down Expand Up @@ -2180,7 +2179,7 @@ class PageService {
}, { new: true });
await PageTagRelation.updateMany({ relatedPage: page._id }, { $set: { isPageTrashed: false } });

this.pageEvent.emit('revert', page, user);
this.pageEvent.emit('revert', page, updatedPage, user);

return updatedPage;
}
Expand Down
10 changes: 8 additions & 2 deletions apps/app/src/server/service/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,14 @@ class SearchService implements SearchQueryParser, SearchResolver {
const pageEvent = this.crowi.event('page');
pageEvent.on('create', this.fullTextSearchDelegator.syncPageUpdated.bind(this.fullTextSearchDelegator));
pageEvent.on('update', this.fullTextSearchDelegator.syncPageUpdated.bind(this.fullTextSearchDelegator));
pageEvent.on('delete', this.fullTextSearchDelegator.syncPageDeleted.bind(this.fullTextSearchDelegator));
pageEvent.on('revert', this.fullTextSearchDelegator.syncPageDeleted.bind(this.fullTextSearchDelegator));
pageEvent.on('delete', (targetPage, deletedPage, user) => {
this.fullTextSearchDelegator.syncPageDeleted.bind(this.fullTextSearchDelegator)(targetPage, user);
this.fullTextSearchDelegator.syncPageUpdated.bind(this.fullTextSearchDelegator)(deletedPage, user);
});
pageEvent.on('revert', (targetPage, revertedPage, user) => {
this.fullTextSearchDelegator.syncPageDeleted.bind(this.fullTextSearchDelegator)(targetPage, user);
this.fullTextSearchDelegator.syncPageUpdated.bind(this.fullTextSearchDelegator)(revertedPage, user);
});
Copy link
Member Author

Choose a reason for hiding this comment

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

page に対す処理と pageEvent 内の es に対する処理が同じになるようにしました

pageEvent.on('deleteCompletely', this.fullTextSearchDelegator.syncPageDeleted.bind(this.fullTextSearchDelegator));
pageEvent.on('syncDescendantsDelete', this.fullTextSearchDelegator.syncDescendantsPagesDeleted.bind(this.fullTextSearchDelegator));
pageEvent.on('updateMany', this.fullTextSearchDelegator.syncPagesUpdated.bind(this.fullTextSearchDelegator));
Expand Down