import { Component , OnInit , ViewEncapsulation } from '@angular/core' ; import { ConfigurationService } from '../core/configuration/configuration.service' ; import { OptionsModel , OptionsModelKeys } from '../models/options.model' ; import { DomSanitizer } from '@angular/platform-browser' ; import { ConfigModel } from '../models/config.model' ; @ Component ( { selector : 'app-homepage' , templateUrl : './homepage.component.html' , styleUrls : [ './homepage.component.scss' ] , encapsulation : ViewEncapsulation . None } ) export class HomepageComponent implements OnInit { config : ConfigModel ; options : OptionsModel = new OptionsModel ( ) ; extensionVersion = '' ; slackChannelNativeUrl ; savingOptions : boolean ; optionsSaved : boolean ; constructor ( private configurationService , private domSanitizer ) { } ngOnInit ( ) { this . populateConfiguration ( ) ; this . populateOptions ( ) ; this . populateExtensionVersion ( ) ; } /**
     * Populates the configuration
     */ populateConfiguration ( ) { this . configurationService . getConfiguration ( ) . subscribe ( ( config ) => { this . config = config ; this . slackChannelNativeUrl = this . domSanitizer . bypassSecurityTrustUrl ( this . config . slackChannelLink ) ; } ) ; } /**
     * Populates the options
     */ populateOptions ( ) { chrome . storage . local . get ( OptionsModelKeys , ( result ) => { this . options = new OptionsModel ( result ) ; console . log ( 'options' , this . options ) ; } ) ; } /**
     * Populates the extension version
     */ populateExtensionVersion ( ) { this . configurationService . getExtensionVersion ( ) . subscribe ( version => { this . extensionVersion = version ; } ) ; } saveOptions ( ) { this . optionsSaved = false ; this . savingOptions = true ; chrome . storage . local . set ( this . options , ( ) => { } ) ; setTimeout ( ( ) => { this . savingOptions = false ; this . optionsSaved = true ; } , 2000 ) ; } optionsChanged ( ) { this . optionsSaved = false ; this . savingOptions = false ; } }