From b98338264205906932fb5f671fcde6e2767cf972 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 14 Apr 2021 10:36:34 +0200 Subject: [PATCH] do not mutate Kibana values in defaultsDeep --- src/core/public/ui_settings/ui_settings_client.ts | 4 ++-- src/core/server/ui_settings/ui_settings_client.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/public/ui_settings/ui_settings_client.ts b/src/core/public/ui_settings/ui_settings_client.ts index 47dc2b3bc3e6f..e23fb9c6891a8 100644 --- a/src/core/public/ui_settings/ui_settings_client.ts +++ b/src/core/public/ui_settings/ui_settings_client.ts @@ -34,7 +34,7 @@ export class UiSettingsClient implements IUiSettingsClient { constructor(params: UiSettingsClientParams) { this.api = params.api; this.defaults = cloneDeep(params.defaults); - this.cache = defaultsDeep({ ...this.defaults }, params.initialSettings); + this.cache = defaultsDeep({}, this.defaults, params.initialSettings); params.done$.subscribe({ complete: () => { @@ -177,7 +177,7 @@ You can use \`IUiSettingsClient.get("${key}", defaultValue)\`, which will just r try { const { settings } = await this.api.batchSet(key, newVal); - this.cache = defaultsDeep({ ...defaults }, settings); + this.cache = defaultsDeep({}, defaults, settings); this.saved$.next({ key, newValue: newVal, oldValue: initialVal }); return true; } catch (error) { diff --git a/src/core/server/ui_settings/ui_settings_client.ts b/src/core/server/ui_settings/ui_settings_client.ts index 11a061ab49497..ae7eb04caea61 100644 --- a/src/core/server/ui_settings/ui_settings_client.ts +++ b/src/core/server/ui_settings/ui_settings_client.ts @@ -152,7 +152,7 @@ export class UiSettingsClient implements IUiSettingsClient { } const userProvided = await this.getUserProvided(); - const result = defaultsDeep({ ...userProvided }, this.defaults); + const result = defaultsDeep({}, userProvided, this.defaults); this.rawCache.set(result);