]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/core/rest/rest-table.ts
Update translations
[github/Chocobozzz/PeerTube.git] / client / src / app / core / rest / rest-table.ts
index a5b48f10c6f17dc85108ce7e049003c1ee0a378a..ec5646b5df6320161d53ef7ee94dfb9d3a0369dd 100644 (file)
@@ -1,10 +1,11 @@
-import * as debug from 'debug'
+import debug from 'debug'
 import { LazyLoadEvent, SortMeta } from 'primeng/api'
 import { ActivatedRoute, Router } from '@angular/router'
+import { logger } from '@root-helpers/logger'
 import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
 import { RestPagination } from './rest-pagination'
 
-const logger = debug('peertube:tables:RestTable')
+const debugLogger = debug('peertube:tables:RestTable')
 
 export abstract class RestTable {
 
@@ -34,49 +35,42 @@ export abstract class RestTable {
       try {
         this.sort = JSON.parse(result)
       } catch (err) {
-        console.error('Cannot load sort of local storage key ' + this.getSortLocalStorageKey(), err)
+        logger.error('Cannot load sort of local storage key ' + this.getSortLocalStorageKey(), err)
       }
     }
   }
 
+  saveSort () {
+    peertubeLocalStorage.setItem(this.getSortLocalStorageKey(), JSON.stringify(this.sort))
+  }
+
   loadLazy (event: LazyLoadEvent) {
-    logger('Load lazy %o.', event)
+    debugLogger('Load lazy %o.', event)
 
     this.sort = {
       order: event.sortOrder,
       field: event.sortField
     }
 
+    this.rowsPerPage = event.rows
+
     this.pagination = {
       start: event.first,
       count: this.rowsPerPage
     }
 
+    this.expandedRows = {}
+
     this.reloadData()
     this.saveSort()
   }
 
-  saveSort () {
-    peertubeLocalStorage.setItem(this.getSortLocalStorageKey(), JSON.stringify(this.sort))
-  }
-
-  onPage (event: { first: number, rows: number }) {
-    logger('On page %o.', event)
-
-    if (this.rowsPerPage !== event.rows) {
-      this.rowsPerPage = event.rows
-      this.pagination = {
-        start: event.first,
-        count: this.rowsPerPage
-      }
-
-      this.reloadData()
+  onSearch (search: string) {
+    this.pagination = {
+      start: 0,
+      count: this.rowsPerPage
     }
 
-    this.expandedRows = {}
-  }
-
-  onSearch (search: string) {
     this.search = search
     this.reloadData()
   }