fix loading feed

This commit is contained in:
john 2025-06-11 23:12:03 +02:00
parent cf5494c15b
commit 95ea2a5f23
4 changed files with 54 additions and 71 deletions

View file

@ -29,34 +29,22 @@ export class PostsService {
return Post.fromDto(response.data.post)
}
async loadPublicFeed(cursor: string | null, amount: number | null): Promise<Post[]> {
const response = await this.client.GET('/posts', {
query: { cursor, amount },
credentials: 'include',
})
if (!response.data) {
return []
}
return response.data?.posts.map((post) => Post.fromDto(post))
}
async loadByAuthor(
username: string,
async loadPublicFeed(
cursor: string | null,
amount: number | null,
): Promise<Post[]> {
): Promise<{ posts: Post[]; next: string | null }> {
const response = await this.client.GET('/posts', {
query: { From: cursor ?? undefined, Amount: amount ?? undefined, Author: username },
params: {
query: { From: cursor ?? undefined, Amount: amount ?? undefined },
},
credentials: 'include',
})
if (!response.data) {
return []
return { posts: [], next: null }
}
return response.data?.posts.map((post) => Post.fromDto(post))
return { posts: response.data.posts.map(Post.fromDto), next: response.data.next }
}
async addReaction(postId: string, emoji: string): Promise<void> {