]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-main/users/user-history.service.ts
Add ability to delete history element
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / users / user-history.service.ts
index bb87dcba872d3a1d1d7498bb11ea9abbab0255c0..e28bcdca943c1dc31679979ad0c4f4f4b3fda6f8 100644 (file)
@@ -19,11 +19,12 @@ export class UserHistoryService {
   ) {}
 
   getUserVideosHistory (historyPagination: ComponentPaginationLight, search?: string) {
-    const pagination = this.restService.componentPaginationToRestPagination(historyPagination)
+    const pagination = this.restService.componentToRestPagination(historyPagination)
 
     let params = new HttpParams()
     params = this.restService.addRestGetParams(params, pagination)
-    params = params.append('search', search)
+
+    if (search) params = params.append('search', search)
 
     return this.authHttp
                .get<ResultList<Video>>(UserHistoryService.BASE_USER_VIDEOS_HISTORY_URL, { params })
@@ -33,7 +34,13 @@ export class UserHistoryService {
                )
   }
 
-  deleteUserVideosHistory () {
+  deleteUserVideoHistoryElement (video: Video) {
+    return this.authHttp
+               .delete(UserHistoryService.BASE_USER_VIDEOS_HISTORY_URL + '/' + video.id)
+               .pipe(catchError(err => this.restExtractor.handleError(err)))
+  }
+
+  clearAllUserVideosHistory () {
     return this.authHttp
                .post(UserHistoryService.BASE_USER_VIDEOS_HISTORY_URL + '/remove', {})
                .pipe(