diff --git a/tabby-core/src/services/config.service.ts b/tabby-core/src/services/config.service.ts index 7baaf926..aa21d0c6 100644 --- a/tabby-core/src/services/config.service.ts +++ b/tabby-core/src/services/config.service.ts @@ -270,8 +270,8 @@ export class ConfigService { } private emitChange (): void { - this.changed.next() this.vault.setStore(this.store.vault) + this.changed.next() } private migrate (config) { diff --git a/tabby-settings/src/components/configSyncSettingsTab.component.pug b/tabby-settings/src/components/configSyncSettingsTab.component.pug index f1d2e470..00a31bb3 100644 --- a/tabby-settings/src/components/configSyncSettingsTab.component.pug +++ b/tabby-settings/src/components/configSyncSettingsTab.component.pug @@ -96,7 +96,10 @@ ul.nav-tabs(ngbNav, #nav='ngbNav') li(ngbNavItem) a(ngbNavLink, translate) Advanced ng-template(ngbNavContent) - .form-line + .alert.alert-info(*ngIf='config.store.encrypted') + div(translate) Partial config sync is not possible when the config is encrypted via Vault. + + .form-line(*ngIf='!config.store.encrypted') .header .title(translate) Sync hotkeys toggle( @@ -104,7 +107,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav') (ngModelChange)='config.save()', ) - .form-line + .form-line(*ngIf='!config.store.encrypted') .header .title(translate) Sync window settings toggle( @@ -112,7 +115,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav') (ngModelChange)='config.save()', ) - .form-line + .form-line(*ngIf='!config.store.encrypted') .header .title(translate) Sync Vault toggle( diff --git a/tabby-settings/src/services/configSync.service.ts b/tabby-settings/src/services/configSync.service.ts index 922d09c4..1542fb28 100644 --- a/tabby-settings/src/services/configSync.service.ts +++ b/tabby-settings/src/services/configSync.service.ts @@ -86,7 +86,7 @@ export class ConfigSyncService { return } try { - const data = this.readConfigDataForSync() + const data = await this.readConfigDataForSync() const remoteData = yaml.load((await this.getConfig(this.config.store.configSync.configID)).content) as any for (const part of OPTIONAL_CONFIG_PARTS) { if (!this.config.store.configSync.parts[part]) { @@ -113,16 +113,19 @@ export class ConfigSyncService { try { const config = await this.getConfig(this.config.store.configSync.configID) const data = yaml.load(config.content) as any + const localData = yaml.load(this.config.readRaw()) as any data.configSync = localData.configSync - for (const part of OPTIONAL_CONFIG_PARTS) { - if (!this.config.store.configSync.parts[part]) { - data[part] = localData[part] + if (!data.encrypted) { + for (const part of OPTIONAL_CONFIG_PARTS) { + if (!this.config.store.configSync.parts[part]) { + data[part] = localData[part] + } } } - this.writeConfigDataFromSync(data) + await this.writeConfigDataFromSync(data) this.logger.debug('Config downloaded') } catch (error) { this.logger.error('Download failed:', error) @@ -130,14 +133,16 @@ export class ConfigSyncService { } } - private readConfigDataForSync (): any { - const data = yaml.load(this.config.readRaw()) as any + private async readConfigDataForSync (): Promise { + const data = yaml.load(await this.platform.loadConfig()) as any delete data.configSync return data } - private writeConfigDataFromSync (data: any) { - this.config.writeRaw(yaml.dump(data)) + private async writeConfigDataFromSync (data: any) { + await this.platform.saveConfig(yaml.dump(data)) + await this.config.load() + await this.config.save() } private async request (method: 'GET'|'POST'|'PATCH', url: string, params = {}) {