Страницы всегда загружаются 2 раза angular FireBase - PullRequest
0 голосов
/ 14 марта 2020

я следовал этому уроку https://fireship.io/lessons/angularfire-google-oauth/ результат здесь https://kewirus-v1.web.app когда я перенаправлен на панель инструментов или страницы, содержащие компонент заголовка, он всегда загружается 2 раза, иногда вторая загрузка завершается sh когда-нибудь застряло.

кто-нибудь знает, что происходит?

вот мой header.component.ts

@Component({
  selector: 'ngx-header',
  styleUrls: ['./header.component.scss'],
  templateUrl: './header.component.html',
})
export class HeaderComponent implements OnInit {
  @ViewChild('contentTemplate', { static: false }) contentTemplate: TemplateRef<any>;
  private destroy$: Subject<void> = new Subject<void>();
  userPictureOnly: boolean = false;
  user: any;
  userMenu = [{ title: 'Profile' }, { title: 'Log out' }];
  loggedIn: boolean;

  constructor(private sidebarService: NbSidebarService,
    private menuService: NbMenuService,
    private themeService: NbThemeService,
    private userService: UserData,
    private windowService: NbWindowService,
    public auth: AuthService,
    @Inject(NB_WINDOW) private window,
    private router: Router,
    private breakpointService: NbMediaBreakpointsService) {

  }
  openWindow() {
    this.windowService.open(
      this.contentTemplate,
      { title: 'Free Member' },
    );
  }
  signOut(): void {
    this.auth.signOut();
    this.router.navigateByUrl('/auth/signin');
  }
  ngOnInit() {

    //logout
    this.menuService.onItemClick()
      .pipe(
        filter(({ tag }) => tag === 'my-context-menu'), map(({ item: { title } }) => title)).subscribe(title => {
          if (title == "Log out") {
            this.signOut();
          }
        });
    //logout
  }

  toggleSidebar(): boolean {
    this.sidebarService.toggle(true, 'menu-sidebar');
    return false;
  }

  navigateHome() {
    this.menuService.navigateHome();
    return false;
  }
  openChat() {
    this.router.navigateByUrl('/pages/chat');
  }
}

и вот мой заголовок html

<div class="header-container" *nbIsGranted="['view', 'user']">
  <nb-actions size="small">
    <nb-action style="cursor: pointer;padding: 20px;"><a (click)="openWindow()">Free Member</a></nb-action>
    <nb-action class="control-item">
      <nb-search type="modal-zoomin" tag="modal-zoomin"></nb-search>
    </nb-action>
    <nb-action class="control-item" icon="email-outline" (click)="openChat()"></nb-action>
    <nb-action class="control-item" icon="bell-outline"></nb-action>
    <nb-action class="user-action" *ngIf="auth.user$ | async as user">
      <nb-user [nbContextMenu]="userMenu" [onlyPicture]="userPictureOnly" [name]="user?.displayName" [picture]="user?.photoURL" nbContextMenuTag="my-context-menu">
      </nb-user>  
    </nb-action>
  </nb-actions>
</div>
...