From 8e11a1b37cb1d226acfe494f8821e5eb6e874dd0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 8 Apr 2020 10:49:26 +0200 Subject: Fix sort in admin tables --- client/src/app/shared/rest/rest-table.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'client/src/app/shared/rest/rest-table.ts') diff --git a/client/src/app/shared/rest/rest-table.ts b/client/src/app/shared/rest/rest-table.ts index a33e99e25..63e0e1b97 100644 --- a/client/src/app/shared/rest/rest-table.ts +++ b/client/src/app/shared/rest/rest-table.ts @@ -13,7 +13,8 @@ export abstract class RestTable { protected search: string private searchStream: Subject - private sortLocalStorageKey = 'rest-table-sort-' + this.constructor.name + + abstract getIdentifier (): string initialize () { this.loadSort() @@ -21,13 +22,13 @@ export abstract class RestTable { } loadSort () { - const result = peertubeLocalStorage.getItem(this.sortLocalStorageKey) + const result = peertubeLocalStorage.getItem(this.getSortLocalStorageKey()) if (result) { try { this.sort = JSON.parse(result) } catch (err) { - console.error('Cannot load sort of local storage key ' + this.sortLocalStorageKey, err) + console.error('Cannot load sort of local storage key ' + this.getSortLocalStorageKey(), err) } } } @@ -48,7 +49,7 @@ export abstract class RestTable { } saveSort () { - peertubeLocalStorage.setItem(this.sortLocalStorageKey, JSON.stringify(this.sort)) + peertubeLocalStorage.setItem(this.getSortLocalStorageKey(), JSON.stringify(this.sort)) } initSearch () { @@ -71,4 +72,8 @@ export abstract class RestTable { } protected abstract loadData (): void + + private getSortLocalStorageKey () { + return 'rest-table-sort-' + this.getIdentifier() + } } -- cgit v1.2.3