From e7486b1c8d185659ae4c10632ea068f30e1697cc Mon Sep 17 00:00:00 2001 From: mybearworld <130385691+mybearworld@users.noreply.github.com> Date: Sat, 27 Jul 2024 08:36:40 +0200 Subject: [PATCH] Use more reasonable convention for load more naming --- src/components/Chat.tsx | 2 +- src/lib/api/posts.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/Chat.tsx b/src/components/Chat.tsx index 4e5c794..53c9803 100644 --- a/src/components/Chat.tsx +++ b/src/components/Chat.tsx @@ -32,7 +32,7 @@ export const Chat = (props: ChatProps) => { state.loadChat, state.chatPosts[props.chat], state.loadChatPosts, - state.loadMore, + state.loadMorePosts, state.updateChat, ]), ); diff --git a/src/lib/api/posts.ts b/src/lib/api/posts.ts index 7a2fd1a..53e92db 100644 --- a/src/lib/api/posts.ts +++ b/src/lib/api/posts.ts @@ -86,10 +86,10 @@ export type PostsSlice = { posts: Record>; addPost: (post: SchemaPost) => SchemaPost; loadChatPosts: (id: string) => Promise; - loadMore: ( + loadMorePosts: ( id: string, ) => Promise<{ error: true; message: string } | { error: false }>; - loadPosts: ( + loadPostsByAmount: ( id: string, current: number, ) => Promise< @@ -284,14 +284,14 @@ export const createPostsSlice: Slice = (set, get) => { } loadingPosts.delete(post); }, - loadMore: async (id: string) => { + loadMorePosts: async (id: string) => { const state = get(); const posts = state.chatPosts[id]; if (loadingChats.has(id) || posts?.error) { return { error: false }; } loadingChats.add(id); - const response = await state.loadPosts( + const response = await state.loadPostsByAmount( id, posts?.posts?.filter( (post) => !state.posts[post]?.error && !state.posts[post]?.isDeleted, @@ -320,9 +320,9 @@ export const createPostsSlice: Slice = (set, get) => { if (state.chatPosts[id]) { return; } - state.loadMore(id); + state.loadMorePosts(id); }, - loadPosts: async (id: string, current: number) => { + loadPostsByAmount: async (id: string, current: number) => { const state = get(); await state.finishedAuth(); const newState = get();