aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/app.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/app.component.ts')
-rw-r--r--client/src/app/app.component.ts29
1 files changed, 5 insertions, 24 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index 59966243b..629549ef2 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -18,6 +18,7 @@ import { InstanceConfigWarningModalComponent } from '@app/modal/instance-config-
18import { ServerConfig, UserRole } from '@shared/models' 18import { ServerConfig, UserRole } from '@shared/models'
19import { User } from '@app/shared' 19import { User } from '@app/shared'
20import { InstanceService } from '@app/shared/instance/instance.service' 20import { InstanceService } from '@app/shared/instance/instance.service'
21import { MenuService } from './core/menu/menu.service'
21 22
22@Component({ 23@Component({
23 selector: 'my-app', 24 selector: 'my-app',
@@ -28,9 +29,6 @@ export class AppComponent implements OnInit {
28 @ViewChild('welcomeModal') welcomeModal: WelcomeModalComponent 29 @ViewChild('welcomeModal') welcomeModal: WelcomeModalComponent
29 @ViewChild('instanceConfigWarningModal') instanceConfigWarningModal: InstanceConfigWarningModalComponent 30 @ViewChild('instanceConfigWarningModal') instanceConfigWarningModal: InstanceConfigWarningModalComponent
30 31
31 isMenuDisplayed = true
32 isMenuChangedByUser = false
33
34 customCSS: SafeHtml 32 customCSS: SafeHtml
35 33
36 private serverConfig: ServerConfig 34 private serverConfig: ServerConfig
@@ -50,7 +48,8 @@ export class AppComponent implements OnInit {
50 private themeService: ThemeService, 48 private themeService: ThemeService,
51 private hooks: HooksService, 49 private hooks: HooksService,
52 private location: PlatformLocation, 50 private location: PlatformLocation,
53 private modalService: NgbModal 51 private modalService: NgbModal,
52 public menu: MenuService
54 ) { } 53 ) { }
55 54
56 get instanceName () { 55 get instanceName () {
@@ -78,21 +77,12 @@ export class AppComponent implements OnInit {
78 this.authService.refreshUserInformation() 77 this.authService.refreshUserInformation()
79 } 78 }
80 79
81 // Do not display menu on small screens
82 if (this.screenService.isInSmallView()) {
83 this.isMenuDisplayed = false
84 }
85
86 this.initRouteEvents() 80 this.initRouteEvents()
87 this.injectJS() 81 this.injectJS()
88 this.injectCSS() 82 this.injectCSS()
89 83
90 this.initHotkeys() 84 this.initHotkeys()
91 85
92 fromEvent(window, 'resize')
93 .pipe(debounceTime(200))
94 .subscribe(() => this.onResize())
95
96 this.location.onPopState(() => this.modalService.dismissAll(POP_STATE_MODAL_DISMISS)) 86 this.location.onPopState(() => this.modalService.dismissAll(POP_STATE_MODAL_DISMISS))
97 87
98 this.openModalsIfNeeded() 88 this.openModalsIfNeeded()
@@ -102,15 +92,6 @@ export class AppComponent implements OnInit {
102 return this.authService.isLoggedIn() 92 return this.authService.isLoggedIn()
103 } 93 }
104 94
105 toggleMenu () {
106 this.isMenuDisplayed = !this.isMenuDisplayed
107 this.isMenuChangedByUser = true
108 }
109
110 onResize () {
111 this.isMenuDisplayed = window.innerWidth >= 800 && !this.isMenuChangedByUser
112 }
113
114 private initRouteEvents () { 95 private initRouteEvents () {
115 let resetScroll = true 96 let resetScroll = true
116 const eventsObs = this.router.events 97 const eventsObs = this.router.events
@@ -176,7 +157,7 @@ export class AppComponent implements OnInit {
176 eventsObs.pipe( 157 eventsObs.pipe(
177 filter((e: Event): e is GuardsCheckStart => e instanceof GuardsCheckStart), 158 filter((e: Event): e is GuardsCheckStart => e instanceof GuardsCheckStart),
178 filter(() => this.screenService.isInSmallView()) 159 filter(() => this.screenService.isInSmallView())
179 ).subscribe(() => this.isMenuDisplayed = false) // User clicked on a link in the menu, change the page 160 ).subscribe(() => this.menu.isMenuDisplayed = false) // User clicked on a link in the menu, change the page
180 } 161 }
181 162
182 private injectJS () { 163 private injectJS () {
@@ -249,7 +230,7 @@ export class AppComponent implements OnInit {
249 }, undefined, this.i18n('Focus the search bar')), 230 }, undefined, this.i18n('Focus the search bar')),
250 231
251 new Hotkey('b', (event: KeyboardEvent): boolean => { 232 new Hotkey('b', (event: KeyboardEvent): boolean => {
252 this.toggleMenu() 233 this.menu.toggleMenu()
253 return false 234 return false
254 }, undefined, this.i18n('Toggle the left menu')), 235 }, undefined, this.i18n('Toggle the left menu')),
255 236