diff --git a/app/yarn.lock b/app/yarn.lock index 4b87f48e..74614856 100644 --- a/app/yarn.lock +++ b/app/yarn.lock @@ -131,10 +131,10 @@ dependencies: debug "^4.1.1" -"@terminus-term/node-pty@0.10.0-terminus.2": - version "0.10.0-terminus.2" - resolved "https://registry.yarnpkg.com/@terminus-term/node-pty/-/node-pty-0.10.0-terminus.2.tgz#028c7762d13150984bc800b8cd954ceb7dbcac68" - integrity sha512-vcscP3jldTMZeHv0XVxQjwEtnh0usUQgUWvsXtPRMy2rMjijwC1+8xFp/FKPpLpWYNTN8WWmRjSdiw+qGGU4CQ== +"@terminus-term/node-pty@0.10.0-terminus.3": + version "0.10.0-terminus.3" + resolved "https://registry.yarnpkg.com/@terminus-term/node-pty/-/node-pty-0.10.0-terminus.3.tgz#9dbd64d52afda5079e66265a89d313fe42affab7" + integrity sha512-HvIOts22dnoBXhRfLiK9DyPasuixYVgEUvgqZmOr0B0Ki9tF8e074oYPUtzLRll6Y553QiUzTWhriCS99MChNQ== dependencies: nan "^2.14.0" diff --git a/terminus-settings/package.json b/terminus-settings/package.json index 17ab125a..0b9a2f2e 100644 --- a/terminus-settings/package.json +++ b/terminus-settings/package.json @@ -17,7 +17,8 @@ "author": "Eugene Pankov", "license": "MIT", "devDependencies": { - "@types/deep-equal": "1.0.1" + "@types/deep-equal": "1.0.1", + "utils-decorators": "^1.8.0" }, "peerDependencies": { "@angular/animations": "^9.1.9", diff --git a/terminus-settings/src/components/settingsTab.component.pug b/terminus-settings/src/components/settingsTab.component.pug index f00239b4..7ef1116f 100644 --- a/terminus-settings/src/components/settingsTab.component.pug +++ b/terminus-settings/src/components/settingsTab.component.pug @@ -25,7 +25,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') .title Theme select.form-control( [(ngModel)]='config.store.appearance.theme', - (ngModelChange)='config.save()', + (ngModelChange)='saveConfiguration()', ) option(*ngFor='let theme of themes', [ngValue]='theme.name') {{theme.name}} @@ -34,7 +34,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') .title Tabs location .btn-group( [(ngModel)]='config.store.appearance.tabsLocation', - (ngModelChange)='config.save()', + (ngModelChange)='saveConfiguration()', ngbRadioGroup ) label.btn.btn-secondary(ngbButtonLabel) @@ -71,7 +71,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') .title Tabs width .btn-group( [(ngModel)]='config.store.appearance.flexTabs', - (ngModelChange)='config.save()', + (ngModelChange)='saveConfiguration()', ngbRadioGroup ) label.btn.btn-secondary(ngbButtonLabel) @@ -97,7 +97,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') toggle( [(ngModel)]='config.store.appearance.vibrancy', - (ngModelChange)='config.save()' + (ngModelChange)='saveConfiguration()' ) .form-line(*ngIf='config.store.appearance.vibrancy && isFluentVibrancySupported') @@ -105,7 +105,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') .title Background type .btn-group( [(ngModel)]='config.store.appearance.vibrancyType', - (ngModelChange)='config.save()', + (ngModelChange)='saveConfiguration()', ngbRadioGroup ) label.btn.btn-secondary(ngbButtonLabel) @@ -129,7 +129,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') input( type='range', [(ngModel)]='config.store.appearance.opacity', - (ngModelChange)='config.save(); (hostApp.platform === Platform.Linux && config.requestRestart())', + (ngModelChange)='saveConfiguration(); (hostApp.platform === Platform.Linux && config.requestRestart())', min='0.4', max='1', step='0.01' @@ -148,7 +148,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') .btn-group( [(ngModel)]='config.store.appearance.frame', - (ngModelChange)='config.save(); config.requestRestart()', + (ngModelChange)='saveConfiguration(true)', ngbRadioGroup ) label.btn.btn-secondary(ngbButtonLabel) @@ -180,7 +180,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') .btn-group( [(ngModel)]='config.store.appearance.dock', - (ngModelChange)='config.save(); docking.dock()', + (ngModelChange)='saveConfiguration(); docking.dock()', ngbRadioGroup ) label.btn.btn-secondary(ngbButtonLabel) @@ -226,7 +226,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') div( [(ngModel)]='config.store.appearance.dockScreen', - (ngModelChange)='config.save(); docking.dock()', + (ngModelChange)='saveConfiguration(); docking.dock()', ngbRadioGroup ) label.btn.btn-secondary(ngbButtonLabel) @@ -250,7 +250,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') .description Keep docked terminal always on top toggle( [(ngModel)]='config.store.appearance.dockAlwaysOnTop', - (ngModelChange)='config.save(); docking.dock()', + (ngModelChange)='saveConfiguration(); docking.dock()', ) .form-line(*ngIf='config.store.appearance.dock != "off"') @@ -259,7 +259,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') input( type='range', [(ngModel)]='config.store.appearance.dockFill', - (mouseup)='config.save(); docking.dock()', + (mouseup)='saveConfiguration(); docking.dock()', min='0.05', max='1', step='0.01' @@ -271,7 +271,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') .description Hides the docked terminal when you click away. toggle( [(ngModel)]='config.store.appearance.dockHideOnBlur', - (ngModelChange)='config.save(); ', + (ngModelChange)='saveConfiguration(); ', ) .form-line @@ -288,21 +288,21 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') .description We're only tracking your Terminus and OS versions. toggle( [(ngModel)]='config.store.enableAnalytics', - (ngModelChange)='config.save(); config.requestRestart()', + (ngModelChange)='saveConfiguration(true)', ) .form-line .header .title Automatic Updates .description Enable automatic installation of updates when they become available. - toggle([(ngModel)]='config.store.enableAutomaticUpdates', (ngModelChange)='config.save()') + toggle([(ngModel)]='config.store.enableAutomaticUpdates', (ngModelChange)='saveConfiguration()') .form-line .header .title Custom CSS textarea.form-control( [(ngModel)]='config.store.appearance.css', - (ngModelChange)='config.save()', + (ngModelChange)='saveConfiguration()', ) ngb-tab(id='hotkeys') @@ -331,7 +331,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') td.pr-5 multi-hotkey-input( [model]='getHotkey(hotkey.id) || []', - (modelChange)='setHotkey(hotkey.id, $event); config.save(); docking.dock()' + (modelChange)='setHotkey(hotkey.id, $event); saveConfiguration(); docking.dock()' ) ngb-tab(*ngFor='let provider of settingsProviders', [id]='provider.id') diff --git a/terminus-settings/src/components/settingsTab.component.ts b/terminus-settings/src/components/settingsTab.component.ts index 664db965..5922fa5e 100644 --- a/terminus-settings/src/components/settingsTab.component.ts +++ b/terminus-settings/src/components/settingsTab.component.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import * as yaml from 'js-yaml' +import { debounce } from 'utils-decorators/dist/cjs' import { Subscription } from 'rxjs' import { Component, Inject, Input, HostBinding, NgZone } from '@angular/core' import { @@ -104,6 +105,14 @@ export class SettingsTabComponent extends BaseTabComponent { this.hostApp.relaunch() } + @debounce(500) + saveConfiguration (requireRestart?: boolean) { + this.config.save() + if (requireRestart) { + this.config.requestRestart() + } + } + saveConfigFile () { if (this.isConfigFileValid()) { this.config.writeRaw(this.configFile) diff --git a/terminus-settings/yarn.lock b/terminus-settings/yarn.lock index 87f1fd54..01264eea 100644 --- a/terminus-settings/yarn.lock +++ b/terminus-settings/yarn.lock @@ -6,3 +6,15 @@ version "1.0.1" resolved "https://registry.yarnpkg.com/@types/deep-equal/-/deep-equal-1.0.1.tgz#71cfabb247c22bcc16d536111f50c0ed12476b03" integrity sha512-mMUu4nWHLBlHtxXY17Fg6+ucS/MnndyOWyOe7MmwkoMYxvfQU2ajtRaEvqSUv+aVkMqH/C0NCI8UoVfRNQ10yg== + +tinyqueue@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/tinyqueue/-/tinyqueue-2.0.3.tgz#64d8492ebf39e7801d7bd34062e29b45b2035f08" + integrity sha512-ppJZNDuKGgxzkHihX8v9v9G5f+18gzaTfrukGrq6ueg0lmH4nqVnA2IPG0AEH3jKEk2GRJCUhDoqpoiw3PHLBA== + +utils-decorators@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/utils-decorators/-/utils-decorators-1.8.0.tgz#6897ce2e57b4a92b18c37fa1a3926f170edbfaa8" + integrity sha512-anKv6Zkebhfyh6exTg3mgvKRYA9fDLkRDbIvbs15m5ridTq0uKqsiBwr222BtJToXNImCJzwkN00F7vL4aKldg== + dependencies: + tinyqueue "^2.0.3"