Skip to content

Commit

Permalink
fix: clicking on back button after post creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Alipov committed Nov 28, 2024
1 parent 3cc39d8 commit 589c862
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
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])];
}
newState.pages = updatedPages;

Expand Down

0 comments on commit 589c862

Please sign in to comment.