import { Component , OnInit } from '@angular/core' ; import { Router } from '@angular/router' ; import { TranslateService } from '@ngx-translate/core' ; import { remote } from 'electron' ; import { AppConfig } from '../environments/environment' ; import { ElectronService } from './providers/electron.service' ; import { SettingsService } from './providers/settings.service' ; import { TwitchAuthService } from './providers/twitch-auth-graphql.service' ; import { TwitchService } from './providers/twitch.service' ; const mainWindow = remote . getGlobal ( 'mainWindow' ) ; const authToken = localStorage . getItem ( 'authToken' ) ; @ Component ( { selector : 'tw-root' , templateUrl : './app.component.html' , styleUrls : [ './app.component.scss' ] } ) export class AppComponent implements OnInit { sidebarState = 'visible' ; constructor ( public electronService , private translate , private router , private twitchAuthService , private twitchService , private settingsService ) { translate . setDefaultLang ( 'en' ) ; console . log ( 'AppConfig' , AppConfig ) ; if ( electronService . isElectron ( ) ) { console . log ( 'Mode electron' ) ; console . log ( 'Electron ipcRenderer' , electronService . ipcRenderer ) ; console . log ( 'NodeJS childProcess' , electronService . childProcess ) ; } else { console . log ( 'Mode web' ) ; } } ngOnInit ( ) { if ( authToken && this . settingsService . getConfig ( ) . autologin ) { this . twitchAuthService . setAuthToken ( authToken ) ; } else { localStorage . removeItem ( 'authToken' ) ; } this . router . navigate ( [ '/games' ] ) ; } closeWindow ( ) { mainWindow . close ( ) ; } maximizeWindow ( ) { if ( mainWindow . isMaximized ( ) ) { mainWindow . unmaximize ( ) ; } else { mainWindow . maximize ( ) ; } } minimizeWindow ( ) { mainWindow . minimize ( ) ; } enterFullscreen ( ) { mainWindow . setFullScreen ( ! mainWindow . isFullScreen ( ) ) ; } toggleSidebar ( ) { if ( this . sidebarState === 'visible' ) { this . sidebarState = 'hidden' ; } else if ( this . sidebarState === 'hidden' ) { this . sidebarState = 'visible' ; } } }