Skip to content

Commit 841e565

Browse files
committed
fix(admin): do not redirect while caching
1 parent d5eacaa commit 841e565

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/app/components/admin/admin-sidebar/admin-sidebar.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit, ChangeDetectionStrategy, OnDestroy } from '@angular/core';
22
import { IconService, RoutesService, UserService, WindowService } from '../../../services';
3-
import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs';
4-
import { filter, map } from 'rxjs/operators';
3+
import {BehaviorSubject, combineLatest, Observable, Subscription, timer} from 'rxjs';
4+
import {filter, map, mergeMap} from 'rxjs/operators';
55
import { Router } from '@angular/router';
66
import { environment } from 'src/environments/environment';
77

@@ -37,7 +37,10 @@ export class AdminSidebarComponent implements OnInit, OnDestroy {
3737
) { }
3838

3939
ngOnInit(): void {
40-
this._subs.push(this.userService.isTester$.pipe(filter((x) => !x)).subscribe(() => {
40+
this._subs.push(this.userService.forceLogin$.pipe( // wait 3s to load auth status from cache
41+
mergeMap(() => this.userService.isTester$),
42+
filter((x) => !x)
43+
).subscribe(() => {
4144
// Leave admin menu when the users logs off
4245
this.router.navigate(['/']).then();
4346
}));

0 commit comments

Comments
 (0)