Reload overviews page on logout

pull/6126/head
Chocobozzz 2023-12-15 11:23:03 +01:00
parent 675f219639
commit bd1dd8fd95
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 17 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import { Subject } from 'rxjs'
import { Component, OnInit } from '@angular/core'
import { Subject, Subscription, switchMap } from 'rxjs'
import { Component, OnDestroy, OnInit } from '@angular/core'
import { Notifier, ScreenService, User, UserService } from '@app/core'
import { Video } from '@app/shared/shared-main'
import { OverviewService } from './overview.service'
@ -10,7 +10,7 @@ import { VideosOverview } from './videos-overview.model'
templateUrl: './video-overview.component.html',
styleUrls: [ './video-overview.component.scss' ]
})
export class VideoOverviewComponent implements OnInit {
export class VideoOverviewComponent implements OnInit, OnDestroy {
onDataSubject = new Subject<any>()
overviews: VideosOverview[] = []
@ -24,6 +24,8 @@ export class VideoOverviewComponent implements OnInit {
private lastWasEmpty = false
private isLoading = false
private userSub: Subscription
constructor (
private notifier: Notifier,
private userService: UserService,
@ -37,8 +39,18 @@ export class VideoOverviewComponent implements OnInit {
this.userService.getAnonymousOrLoggedUser()
.subscribe(user => this.userMiniature = user)
this.userService.listenAnonymousUpdate()
.subscribe(user => this.userMiniature = user)
this.userSub = this.userService.listenAnonymousUpdate()
.pipe(switchMap(() => this.userService.getAnonymousOrLoggedUser()))
.subscribe(user => {
this.userMiniature = user
this.overviews = []
this.loadMoreResults()
})
}
ngOnDestroy () {
if (this.userSub) this.userSub.unsubscribe()
}
buildVideoChannelBy (object: { videos: Video[] }) {