fix flip of post list (#6234)
This commit is contained in:
parent
9d3c7c9496
commit
58719c82dc
2 changed files with 1 additions and 12 deletions
|
|
@ -11,7 +11,6 @@ import {Screens} from '@constants';
|
|||
import {useServerUrl} from '@context/server';
|
||||
import {debounce} from '@helpers/api/general';
|
||||
import {useIsTablet} from '@hooks/device';
|
||||
import {sortPostsByNewest} from '@utils/post';
|
||||
|
||||
import Intro from './intro';
|
||||
|
||||
|
|
@ -44,7 +43,7 @@ const ChannelPostList = ({
|
|||
const onEndReached = useCallback(debounce(async () => {
|
||||
if (!fetchingPosts.current && canLoadPosts.current && posts.length) {
|
||||
fetchingPosts.current = true;
|
||||
const lastPost = sortPostsByNewest(posts)[0];
|
||||
const lastPost = posts[posts.length - 1];
|
||||
const result = await fetchPostsBefore(serverUrl, channelId, lastPost.id);
|
||||
canLoadPosts.current = ((result as ProcessedPosts).posts?.length ?? 1) > 0;
|
||||
fetchingPosts.current = false;
|
||||
|
|
|
|||
|
|
@ -62,16 +62,6 @@ export function shouldIgnorePost(post: Post): boolean {
|
|||
return Post.IGNORE_POST_TYPES.includes(post.type);
|
||||
}
|
||||
|
||||
export const sortPostsByNewest = (posts: PostModel[]) => {
|
||||
return posts.sort((a, b) => {
|
||||
if (a.createAt > b.createAt) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
});
|
||||
};
|
||||
|
||||
export const processPostsFetched = (data: PostResponse) => {
|
||||
const order = data.order;
|
||||
const posts = Object.values(data.posts) as Post[];
|
||||
|
|
|
|||
Loading…
Reference in a new issue