Skip to content

Commit 589c862

Browse files
author
Dima Alipov
committed
fix: clicking on back button after post creation
1 parent 3cc39d8 commit 589c862

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Diff for: src/discussions/posts/data/hooks.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ const usePostList = (ids) => {
1111

1212
const sortedIds = useMemo(() => {
1313
posts.forEach((post) => {
14-
if (post.pinned) {
15-
pinnedPostsIds.push(post.id);
16-
} else {
17-
unpinnedPostsIds.push(post.id);
14+
if (post) {
15+
if (post.pinned) {
16+
pinnedPostsIds.push(post.id);
17+
} else {
18+
unpinnedPostsIds.push(post.id);
19+
}
1820
}
1921
});
2022

Diff for: src/discussions/posts/data/slices.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const threadsSlice = createSlice({
9292
if (!updatedPages[page - 1]) {
9393
updatedPages[page - 1] = ids;
9494
} else {
95-
updatedPages[page - 1] = [...new Set([...updatedPages[page - 1], ...ids])];
95+
updatedPages[page - 1] = [...new Set([updatedPages[page - 1], ...ids])];
9696
}
9797
newState.pages = updatedPages;
9898

0 commit comments

Comments
 (0)