From d7b305bf2995831f7a605da694335ab969236c59 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Mon, 24 Dec 2018 17:22:27 +0100 Subject: [PATCH] fixes in profile editor --- .../components/shellSettingsTab.component.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/terminus-terminal/src/components/shellSettingsTab.component.ts b/terminus-terminal/src/components/shellSettingsTab.component.ts index 1d509d05..e887e53c 100644 --- a/terminus-terminal/src/components/shellSettingsTab.component.ts +++ b/terminus-terminal/src/components/shellSettingsTab.component.ts @@ -1,5 +1,6 @@ import { Component } from '@angular/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' +import { Subscription } from 'rxjs' import { ConfigService, ElectronService, HostAppService, Platform } from 'terminus-core' import { EditProfileModalComponent } from './editProfileModal.component' import { IShell, Profile } from '../api' @@ -12,6 +13,7 @@ export class ShellSettingsTabComponent { shells: IShell[] = [] profiles: Profile[] = [] Platform = Platform + private configSubscription: Subscription constructor ( public config: ConfigService, @@ -21,13 +23,24 @@ export class ShellSettingsTabComponent { private ngbModal: NgbModal, ) { config.store.terminal.environment = config.store.terminal.environment || {} - this.profiles = config.store.terminal.profiles + this.configSubscription = this.config.changed$.subscribe(() => { + this.reload() + }) + this.reload() } async ngOnInit () { this.shells = await this.terminalService.shells$.toPromise() } + ngOnDestroy () { + this.configSubscription.unsubscribe() + } + + reload () { + this.profiles = this.config.store.terminal.profiles + } + pickWorkingDirectory () { let shell = this.shells.find(x => x.id === this.config.store.terminal.shell) console.log(shell) @@ -45,7 +58,8 @@ export class ShellSettingsTabComponent { name: shell.name, sessionOptions: this.terminalService.optionsFromShell(shell), } - this.config.store.terminal.profiles.push(profile) + this.profiles.push(profile) + this.config.store.terminal.profiles = this.profiles this.config.save() }