diff --git a/src/app/root/home/home.component.ts b/src/app/root/home/home.component.ts index 44e91a190e8d3e7887b8ed38339e9d02aeea2969..b3c1a77c7c8138a81f4da1ff772d28777d709cfa 100644 --- a/src/app/root/home/home.component.ts +++ b/src/app/root/home/home.component.ts @@ -132,13 +132,16 @@ export class HomeComponent implements OnInit, OnDestroy { return; } - this.userService.loginNotifier.pipe(takeUntil(this._destroy)).subscribe(isLoggedIn => { + this.userService.loginNotifier.pipe(takeUntil(this._destroy), distinctUntilChanged()).subscribe(isLoggedIn => { this.updateFooterElements(isLoggedIn); this.canModifyQuiz = !environment.requireLoginToCreateQuiz || (isLoggedIn && this.userService.isAuthorizedFor(UserRole.QuizAdmin)); this.canUsePublicQuizzes = !environment.requireLoginToCreateQuiz || (isLoggedIn && this.userService.isAuthorizedFor(UserRole.CreateQuiz)); }); - this.storageService.stateNotifier.pipe(takeUntil(this._destroy), filter(state => state === DbState.Initialized)).subscribe(state => { + const params$ = this.activatedRoute.paramMap.pipe(distinctUntilChanged(), takeUntil(this._destroy)); + const state$ = this.storageService.stateNotifier.pipe(filter(val => val !== DbState.Destroy), distinctUntilChanged(), takeUntil(this._destroy)); + + state$.pipe(filter(state => state === DbState.Initialized)).subscribe(() => { this.cleanUpSessionStorage(); this.storageService.db.getAllQuiznames().then(quizNames => { this._ownQuizzes = quizNames; @@ -158,14 +161,9 @@ export class HomeComponent implements OnInit, OnDestroy { this.ownPublicQuizAmount = val; }); } - }); - const params$ = this.activatedRoute.paramMap.pipe(distinctUntilChanged(), takeUntil(this._destroy)); - - this.storageService.stateNotifier.pipe(filter(val => val !== DbState.Destroy), - distinctUntilChanged(), takeUntil(this._destroy), switchMapTo(params$)).subscribe(async params => { - + state$.pipe(switchMapTo(params$)).subscribe(async params => { if (!Object.keys(params).length || !params.get('themeId') || !params.get('languageId')) { const theme = this.storageService.db.Config.get(StorageKey.DefaultTheme); if (!theme) {