diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-08 10:49:26 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-04-08 10:49:26 +0200 |
commit | 8e11a1b37cb1d226acfe494f8821e5eb6e874dd0 (patch) | |
tree | c7444cdf17dddd9debacf66dbaa54e8ee04e4b5b /client/src/app/shared/rest | |
parent | 14f83c68f11da3435940504fa4000193fb4943be (diff) | |
download | PeerTube-8e11a1b37cb1d226acfe494f8821e5eb6e874dd0.tar.gz PeerTube-8e11a1b37cb1d226acfe494f8821e5eb6e874dd0.tar.zst PeerTube-8e11a1b37cb1d226acfe494f8821e5eb6e874dd0.zip |
Fix sort in admin tables
Diffstat (limited to 'client/src/app/shared/rest')
-rw-r--r-- | client/src/app/shared/rest/rest-table.ts | 13 |
1 files changed, 9 insertions, 4 deletions
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 { | |||
13 | 13 | ||
14 | protected search: string | 14 | protected search: string |
15 | private searchStream: Subject<string> | 15 | private searchStream: Subject<string> |
16 | private sortLocalStorageKey = 'rest-table-sort-' + this.constructor.name | 16 | |
17 | abstract getIdentifier (): string | ||
17 | 18 | ||
18 | initialize () { | 19 | initialize () { |
19 | this.loadSort() | 20 | this.loadSort() |
@@ -21,13 +22,13 @@ export abstract class RestTable { | |||
21 | } | 22 | } |
22 | 23 | ||
23 | loadSort () { | 24 | loadSort () { |
24 | const result = peertubeLocalStorage.getItem(this.sortLocalStorageKey) | 25 | const result = peertubeLocalStorage.getItem(this.getSortLocalStorageKey()) |
25 | 26 | ||
26 | if (result) { | 27 | if (result) { |
27 | try { | 28 | try { |
28 | this.sort = JSON.parse(result) | 29 | this.sort = JSON.parse(result) |
29 | } catch (err) { | 30 | } catch (err) { |
30 | console.error('Cannot load sort of local storage key ' + this.sortLocalStorageKey, err) | 31 | console.error('Cannot load sort of local storage key ' + this.getSortLocalStorageKey(), err) |
31 | } | 32 | } |
32 | } | 33 | } |
33 | } | 34 | } |
@@ -48,7 +49,7 @@ export abstract class RestTable { | |||
48 | } | 49 | } |
49 | 50 | ||
50 | saveSort () { | 51 | saveSort () { |
51 | peertubeLocalStorage.setItem(this.sortLocalStorageKey, JSON.stringify(this.sort)) | 52 | peertubeLocalStorage.setItem(this.getSortLocalStorageKey(), JSON.stringify(this.sort)) |
52 | } | 53 | } |
53 | 54 | ||
54 | initSearch () { | 55 | initSearch () { |
@@ -71,4 +72,8 @@ export abstract class RestTable { | |||
71 | } | 72 | } |
72 | 73 | ||
73 | protected abstract loadData (): void | 74 | protected abstract loadData (): void |
75 | |||
76 | private getSortLocalStorageKey () { | ||
77 | return 'rest-table-sort-' + this.getIdentifier() | ||
78 | } | ||
74 | } | 79 | } |