This reverts commit 59b4366edd.
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
import { selectThreadsByIds } from './selectors';
|
||||
|
||||
export const usePostList = (ids) => {
|
||||
const posts = useSelector(selectThreadsByIds(ids));
|
||||
const pinnedPostsIds = [];
|
||||
const unpinnedPostsIds = [];
|
||||
|
||||
const sortedIds = useMemo(() => {
|
||||
posts.forEach((post) => {
|
||||
if (post.pinned) {
|
||||
pinnedPostsIds.push(post.id);
|
||||
} else {
|
||||
unpinnedPostsIds.push(post.id);
|
||||
}
|
||||
});
|
||||
|
||||
return [...pinnedPostsIds, ...unpinnedPostsIds];
|
||||
}, [posts]);
|
||||
|
||||
return sortedIds;
|
||||
};
|
||||
Reference in New Issue
Block a user