Skip to content

Commit

Permalink
Fix broken pagination in Community Tab
Browse files Browse the repository at this point in the history
The previous PR will cause the page to reset when scrolled.

The root of the issue is that OwnComments lazily shared the same cache key as Community. A quick fix is to just clear the cache when leaving the OwnComments page.
  • Loading branch information
infinite-persistence committed Aug 8, 2023
2 parents d069aa0 + e49d3c2 commit 90468b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ui/component/commentsList/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export default function CommentList(props: Props & StateProps & DispatchProps) {

// Force comments reset
useEffect(() => {
if (page >= 0) {
if (page === 0) {
handleReset();
}
}, [handleReset, page]);
Expand Down
5 changes: 5 additions & 0 deletions ui/page/ownComments/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ export default function OwnComments(props: Props) {
}
}, [page, spinnerRef, isFetchingComments, moreBelow, totalPages]);

// Clear redux when leaving page (because OwnComment is sharing key with CommunityTab)
React.useEffect(() => {
return () => doCommentReset(activeChannelId);
}, [activeChannelId, doCommentReset]);

// **************************************************************************
// **************************************************************************

Expand Down

0 comments on commit 90468b5

Please sign in to comment.