Skip to content

Commit

Permalink
Exclude top level replies to a comment from a deleted channel from th…
Browse files Browse the repository at this point in the history
…e total

comment count
  • Loading branch information
miko committed Nov 12, 2024
1 parent b3930b4 commit 1a0bc9f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions ui/component/comment/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export type Props = {|
threadLevel?: number,
threadDepthLevel?: number,
disabled?: boolean,
updateUiFilteredComments?: (commentId: string) => void,
updateUiFilteredComments?: (commentIds: Array<string>) => void,
|};

type StateProps = {|
Expand Down Expand Up @@ -315,7 +315,8 @@ function CommentView(props: Props & StateProps & DispatchProps) {

if (isCommenterChannelDeleted) {
if (updateUiFilteredComments) {
updateUiFilteredComments(commentId);
const fetchedReplyIds = fetchedReplies.map((r) => r.comment_id);
updateUiFilteredComments([...fetchedReplyIds, commentId]);
}
return null;
}
Expand Down
5 changes: 3 additions & 2 deletions ui/component/commentsList/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ export default function CommentList(props: Props & StateProps & DispatchProps) {
const [debouncedUri, setDebouncedUri] = React.useState();

const [uiFilteredComments, setUiFilteredComments] = React.useState([]);
const updateUiFilteredComments = React.useCallback((commentId) => {
const updateUiFilteredComments = React.useCallback((commentIds) => {
setUiFilteredComments((prevCommentIds) => {
return prevCommentIds.includes(commentId) ? prevCommentIds : [...prevCommentIds, commentId];
const newCommentIds = commentIds.filter((id) => !prevCommentIds.includes(id));
return newCommentIds.length > 0 ? [...prevCommentIds, ...newCommentIds] : prevCommentIds;
});
}, []);

Expand Down
2 changes: 1 addition & 1 deletion ui/component/commentsReplies/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type Props = {|
threadDepthLevel?: number,
onShowMore?: () => void,
threadLevel: number,
updateUiFilteredComments?: (commentId: string) => void,
updateUiFilteredComments?: (commentIds: Array<string>) => void,
|};

type StateProps = {|
Expand Down

0 comments on commit 1a0bc9f

Please sign in to comment.