add and remove reactions
This commit is contained in:
parent
dab626f227
commit
48e7094c5e
6 changed files with 185 additions and 39 deletions
|
@ -48,9 +48,7 @@ export class PostsService {
|
|||
amount: number | null,
|
||||
): Promise<Post[]> {
|
||||
const response = await this.client.GET('/posts', {
|
||||
params: {
|
||||
query: { From: cursor ?? undefined, Amount: amount ?? undefined, Author: username },
|
||||
},
|
||||
query: { From: cursor ?? undefined, Amount: amount ?? undefined, Author: username },
|
||||
credentials: 'include',
|
||||
})
|
||||
|
||||
|
@ -60,6 +58,34 @@ export class PostsService {
|
|||
|
||||
return response.data?.posts.map((post) => Post.fromDto(post))
|
||||
}
|
||||
|
||||
async addReaction(postId: string, emoji: string): Promise<void> {
|
||||
const response = await this.client.POST('/posts/{postId}/reactions', {
|
||||
params: {
|
||||
path: { postId }
|
||||
},
|
||||
body: { emoji },
|
||||
credentials: 'include',
|
||||
})
|
||||
|
||||
if (!response.data) {
|
||||
throw new Error('Failed to add reaction')
|
||||
}
|
||||
}
|
||||
|
||||
async removeReaction(postId: string, emoji: string): Promise<void> {
|
||||
const response = await this.client.DELETE('/posts/{postId}/reactions', {
|
||||
params: {
|
||||
path: { postId }
|
||||
},
|
||||
body: { emoji },
|
||||
credentials: 'include',
|
||||
})
|
||||
|
||||
if (!response.data) {
|
||||
throw new Error('Failed to remove reaction')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface CreatePostMedia {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue