diff options
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/helpers/utils.ts | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/client/src/app/helpers/utils.ts b/client/src/app/helpers/utils.ts index d6ac5b9b4..94f6def26 100644 --- a/client/src/app/helpers/utils.ts +++ b/client/src/app/helpers/utils.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { map } from 'rxjs/operators' | 1 | import { first, map } from 'rxjs/operators' |
2 | import { SelectChannelItem } from 'src/types/select-options-item.model' | 2 | import { SelectChannelItem } from 'src/types/select-options-item.model' |
3 | import { DatePipe } from '@angular/common' | 3 | import { DatePipe } from '@angular/common' |
4 | import { HttpErrorResponse } from '@angular/common/http' | 4 | import { HttpErrorResponse } from '@angular/common/http' |
@@ -23,26 +23,29 @@ function getParameterByName (name: string, url: string) { | |||
23 | 23 | ||
24 | function listUserChannels (authService: AuthService) { | 24 | function listUserChannels (authService: AuthService) { |
25 | return authService.userInformationLoaded | 25 | return authService.userInformationLoaded |
26 | .pipe(map(() => { | 26 | .pipe( |
27 | const user = authService.getUser() | 27 | first(), |
28 | if (!user) return undefined | 28 | map(() => { |
29 | 29 | const user = authService.getUser() | |
30 | const videoChannels = user.videoChannels | 30 | if (!user) return undefined |
31 | if (Array.isArray(videoChannels) === false) return undefined | 31 | |
32 | 32 | const videoChannels = user.videoChannels | |
33 | return videoChannels | 33 | if (Array.isArray(videoChannels) === false) return undefined |
34 | .sort((a, b) => { | 34 | |
35 | if (a.updatedAt < b.updatedAt) return 1 | 35 | return videoChannels |
36 | if (a.updatedAt > b.updatedAt) return -1 | 36 | .sort((a, b) => { |
37 | return 0 | 37 | if (a.updatedAt < b.updatedAt) return 1 |
38 | }) | 38 | if (a.updatedAt > b.updatedAt) return -1 |
39 | .map(c => ({ | 39 | return 0 |
40 | id: c.id, | 40 | }) |
41 | label: c.displayName, | 41 | .map(c => ({ |
42 | support: c.support, | 42 | id: c.id, |
43 | avatarPath: c.avatar?.path | 43 | label: c.displayName, |
44 | }) as SelectChannelItem) | 44 | support: c.support, |
45 | })) | 45 | avatarPath: c.avatar?.path |
46 | }) as SelectChannelItem) | ||
47 | }) | ||
48 | ) | ||
46 | } | 49 | } |
47 | 50 | ||
48 | function getAbsoluteAPIUrl () { | 51 | function getAbsoluteAPIUrl () { |