blob: 74fbe7dea1cd3d5414b1572f9dd2a9b8e045ce8e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import { Component, OnInit } from '@angular/core'
import { empty } from 'rxjs'
import { catchError } from 'rxjs/operators'
import { RestExtractor } from '@app/core'
import { ActivatedRoute, Router } from '@angular/router'
import { AccountService } from '@app/shared/shared-main/account'
@Component({
selector: 'my-actor',
template: ''
})
export class ActorsComponent implements OnInit {
constructor (
private accountService: AccountService,
private route: ActivatedRoute,
private restExtractor: RestExtractor,
private router: Router
) {
}
ngOnInit () {
const accountOrChannelName = this.route.snapshot.params['actorName'].replace('@', '')
this.accountService
.getAccount(accountOrChannelName)
.pipe(
catchError(res => {
if (res.status === 404 && res.message === 'Account not found') {
this.router.navigateByUrl(`/video-channels/${accountOrChannelName}`)
return empty()
}
return this.restExtractor.handleError(res)
})
)
.subscribe(() => {
this.router.navigateByUrl(`/accounts/${accountOrChannelName}`)
})
}
}
|