Browse Source

Update comment repository

pull/1233/head
Hironsan 4 years ago
parent
commit
fc79b531c3
2 changed files with 6 additions and 6 deletions
  1. 8
      frontend/repositories/comment/api.ts
  2. 4
      frontend/repositories/comment/interface.ts

8
frontend/repositories/comment/api.ts

@ -7,11 +7,11 @@ export class FromApiCommentItemListRepository implements CommentItemListReposito
private readonly request = ApiService
) {}
async listAll(projectId: string, q: string): Promise<CommentItemList> {
async listAll(projectId: string, q: string): Promise<CommentItem[]> {
const url = `/projects/${projectId}/comments?q=${q}`
const response = await this.request.get(url)
const items: CommentItemResponse[] = response.data
return CommentItemList.valueOf(items.map(item => CommentItem.valueOf(item)))
return items.map(item => CommentItem.valueOf(item))
}
async list(projectId: string, docId: string): Promise<CommentItemList> {
@ -40,8 +40,8 @@ export class FromApiCommentItemListRepository implements CommentItemListReposito
const response = await this.request.delete(url)
}
async deleteBulk(projectId: string, items: CommentItemList): Promise<void> {
async deleteBulk(projectId: string, items: number[]): Promise<void> {
const url = `/projects/${projectId}/comments`
await this.request.delete(url, { ids: items.ids() })
await this.request.delete(url, { ids: items })
}
}

4
frontend/repositories/comment/interface.ts

@ -11,7 +11,7 @@ export interface CommentItemResponse {
}
export interface CommentItemListRepository {
listAll(projectId: string, q: string): Promise<CommentItemList>
listAll(projectId: string, q: string): Promise<CommentItem[]>
list(projectId: string, docId: string): Promise<CommentItemList>
@ -21,5 +21,5 @@ export interface CommentItemListRepository {
delete(projectId: string, docId: string, item: CommentItem): Promise<void>
deleteBulk(projectId: string, items: CommentItemList): Promise<void>
deleteBulk(projectId: string, items: number[]): Promise<void>
}
Loading…
Cancel
Save