Skip to content
Open
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
10 changes: 6 additions & 4 deletions src/discussions/posts/data/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ const usePostList = (ids) => {

const sortedIds = useMemo(() => {
posts.forEach((post) => {
if (post.pinned) {
pinnedPostsIds.push(post.id);
} else {
unpinnedPostsIds.push(post.id);
if (post) {
if (post.pinned) {
pinnedPostsIds.push(post.id);
} else {
unpinnedPostsIds.push(post.id);
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/discussions/posts/data/slices.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const threadsSlice = createSlice({
if (!updatedPages[page - 1]) {
updatedPages[page - 1] = ids;
} else {
updatedPages[page - 1] = [...new Set([...updatedPages[page - 1], ...ids])];
updatedPages[page - 1] = [...new Set([updatedPages[page - 1], ...ids])];
Copy link
Preview

Copilot AI Mar 6, 2025

Choose a reason for hiding this comment

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

The updatedPages[page - 1] array is not being spread into the set, which may lead to nested arrays and incorrect deduplication. Consider reverting to spreading the array as in the original code: [...new Set([...updatedPages[page - 1], ...ids])].

Suggested change
updatedPages[page - 1] = [...new Set([updatedPages[page - 1], ...ids])];
updatedPages[page - 1] = [...new Set([...updatedPages[page - 1], ...ids])];

Copilot uses AI. Check for mistakes.

}
newState.pages = updatedPages;

Expand Down