Skip to content

Commit

Permalink
[4.x] Improve post-save performance with many Bard and Revealer fields (
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksleight authored Oct 9, 2023
1 parent a9344ba commit eef1f28
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 1 addition & 3 deletions resources/js/components/publish/HasHiddenFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ export default {
let originalValues = new Values(this.values, this.jsonSubmittingFields);
let newValues = new Values(responseValues, this.jsonSubmittingFields);

preserveFields.forEach(dottedKey => {
newValues.set(dottedKey, originalValues.get(dottedKey));
});
newValues.mergeDottedKeys(preserveFields, originalValues);

return newValues.all();
},
Expand Down
14 changes: 14 additions & 0 deletions resources/js/components/publish/Values.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ export default class Values {
return this;
}

mergeDottedKeys(dottedKeys, values) {
let decodedValues = new this.constructor(clone(values.values), values.jsonFields)
.jsonDecode()
.values;

this.jsonDecode();
dottedKeys.forEach(dottedKey => {
data_set(this.values, dottedKey, data_get(decodedValues, dottedKey));
});
this.jsonEncode();

return this;
}

except(dottedKeys) {
return this.jsonDecode()
.rejectValuesByKey(dottedKeys)
Expand Down

0 comments on commit eef1f28

Please sign in to comment.