1- import { Component , OnInit , ViewChild , ElementRef , DoCheck , AfterViewChecked , HostListener , OnDestroy } from '@angular/core' ;
1+ import { Component , OnInit , ViewChild , ElementRef , DoCheck , AfterViewChecked , OnDestroy } from '@angular/core' ;
22import { Router , RouterLink , RouterLinkActive , RouterOutlet } from '@angular/router' ;
33import { trigger , state , style , animate , transition } from '@angular/animations' ;
44import { MatDialog } from '@angular/material/dialog' ;
@@ -94,18 +94,20 @@ export class HomeComponent implements OnInit, DoCheck, AfterViewChecked, OnDestr
9494 private stateService : StateService ,
9595 private deviceInfoService : DeviceInfoService ,
9696 private notificationsService : NotificationsService
97- ) {
98- this . userService . userChange$ . pipe ( takeUntil ( this . onDestroy$ ) )
99- . subscribe ( ( ) => {
100- this . onUserUpdate ( ) ;
101- this . getNotification ( ) ;
102- } ) ;
103- this . couchService . get ( '_node/nonode@nohost/_config/planet' ) . subscribe ( ( res : any ) => this . layout = res . layout || 'classic' ) ;
104- this . onlineStatus = this . stateService . configuration . registrationRequest ;
105- this . deviceType = this . deviceInfoService . getDeviceType ( ) ;
106- this . isMobile = this . deviceType === DeviceType . MOBILE || this . deviceType === DeviceType . SMALL_MOBILE ;
107- this . isAndroid = this . deviceInfoService . isAndroid ( ) ;
108- }
97+ ) {
98+ this . userService . userChange$ . pipe ( takeUntil ( this . onDestroy$ ) )
99+ . subscribe ( ( ) => {
100+ this . onUserUpdate ( ) ;
101+ this . getNotification ( ) ;
102+ } ) ;
103+ this . couchService . get ( '_node/nonode@nohost/_config/planet' ) . subscribe ( ( res : any ) => this . layout = res . layout || 'classic' ) ;
104+ this . onlineStatus = this . stateService . configuration . registrationRequest ;
105+ this . deviceInfoService . watchDeviceType ( ) . pipe ( takeUntil ( this . onDestroy$ ) ) . subscribe ( ( deviceType ) => {
106+ this . deviceType = deviceType ;
107+ this . isMobile = deviceType === DeviceType . MOBILE || deviceType === DeviceType . SMALL_MOBILE ;
108+ } ) ;
109+ this . isAndroid = this . deviceInfoService . isAndroid ( ) ;
110+ }
109111
110112 ngOnInit ( ) {
111113 this . getNotification ( ) ;
@@ -124,9 +126,9 @@ export class HomeComponent implements OnInit, DoCheck, AfterViewChecked, OnDestr
124126 this . subscribeToLogoutClick ( ) ;
125127 }
126128
127- ngDoCheck ( ) {
128- this . onResize ( ) ;
129- }
129+ ngDoCheck ( ) {
130+ this . syncToolbarLayout ( ) ;
131+ }
130132
131133 ngAfterViewChecked ( ) {
132134 const toolbarElement = this . toolbar . nativeElement ;
@@ -151,14 +153,12 @@ export class HomeComponent implements OnInit, DoCheck, AfterViewChecked, OnDestr
151153 this . onDestroy$ . complete ( ) ;
152154 }
153155
154- @HostListener ( 'window:resize' ) onResize ( ) {
155- const isScreenTooNarrow = window . innerWidth < this . classicToolbarWidth ;
156- if ( this . forceModern !== isScreenTooNarrow ) {
157- this . forceModern = isScreenTooNarrow ;
158- }
159- this . deviceType = this . deviceInfoService . getDeviceType ( ) ;
160- this . isMobile = this . deviceType === DeviceType . MOBILE || this . deviceType === DeviceType . SMALL_MOBILE ;
161- }
156+ syncToolbarLayout ( ) {
157+ const isScreenTooNarrow = window . innerWidth < this . classicToolbarWidth ;
158+ if ( this . forceModern !== isScreenTooNarrow ) {
159+ this . forceModern = isScreenTooNarrow ;
160+ }
161+ }
162162
163163 openLanguageSelector ( ) : void {
164164 this . languageComponent ?. openMenu ( ) ;
0 commit comments