Skip to content

Commit

Permalink
do not mutate Kibana values in defaultsDeep
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Apr 14, 2021
1 parent 442ce29 commit b983382
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core/public/ui_settings/ui_settings_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/ui_settings/ui_settings_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit b983382

Please sign in to comment.