Skip to content

Commit

Permalink
Use more reasonable convention for load more naming
Browse files Browse the repository at this point in the history
  • Loading branch information
mybearworld committed Jul 27, 2024
1 parent fc6c5c6 commit e7486b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const Chat = (props: ChatProps) => {
state.loadChat,
state.chatPosts[props.chat],
state.loadChatPosts,
state.loadMore,
state.loadMorePosts,
state.updateChat,
]),
);
Expand Down
12 changes: 6 additions & 6 deletions src/lib/api/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ export type PostsSlice = {
posts: Record<string, Errorable<Post | { isDeleted: true }>>;
addPost: (post: SchemaPost) => SchemaPost;
loadChatPosts: (id: string) => Promise<void>;
loadMore: (
loadMorePosts: (
id: string,
) => Promise<{ error: true; message: string } | { error: false }>;
loadPosts: (
loadPostsByAmount: (
id: string,
current: number,
) => Promise<
Expand Down Expand Up @@ -284,14 +284,14 @@ export const createPostsSlice: Slice<PostsSlice> = (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,
Expand Down Expand Up @@ -320,9 +320,9 @@ export const createPostsSlice: Slice<PostsSlice> = (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();
Expand Down

0 comments on commit e7486b1

Please sign in to comment.