fix: Prevent overriding the ring with empty value

Apparently changing it to an enum field introduced a bug when an empty value from revision would overwrite actual value from the item itself.
This commit is contained in:
Jarosław Marek
2021-05-04 21:30:40 +12:00
parent 15feb9bc58
commit c1157a771c
3 changed files with 3 additions and 2 deletions

View File

@@ -113,7 +113,7 @@ const addRevisionToItem = (item = {
body: '', body: '',
info: '', info: '',
}, revision) => { }, revision) => {
let newItem = Object.assign(Object.assign(Object.assign({}, item), revision), { body: ignoreEmptyRevisionBody(revision, item) }); let newItem = Object.assign(Object.assign(Object.assign({}, item), revision), { ring: revision.ring ? revision.ring : item.ring, body: ignoreEmptyRevisionBody(revision, item) });
if (revisionCreatesNewHistoryEntry(revision)) { if (revisionCreatesNewHistoryEntry(revision)) {
newItem = Object.assign(Object.assign({}, newItem), { revisions: [revision, ...newItem.revisions] }); newItem = Object.assign(Object.assign({}, newItem), { revisions: [revision, ...newItem.revisions] });
} }

File diff suppressed because one or more lines are too long

View File

@@ -141,6 +141,7 @@ const addRevisionToItem = (
let newItem: Item = { let newItem: Item = {
...item, ...item,
...revision, ...revision,
ring: revision.ring ? revision.ring : item.ring, // prevent empty revision ring overriding the one from the item. This one field is special as it's an enum.
body: ignoreEmptyRevisionBody(revision, item), body: ignoreEmptyRevisionBody(revision, item),
}; };