Skip to content

Commit

Permalink
FIX: Reused gloses may be stored as several chunks.
Browse files Browse the repository at this point in the history
Implementation derived from fix #178 (a6e2bab).
  • Loading branch information
benel committed Aug 15, 2024
1 parent 3e93de4 commit 5127f17
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions frontend/src/components/ExistingDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@ function ExistingDocument({ document, relatedTo, setLastUpdate, backend, setShow
const title = extractSubstring(document.dc_title || 'Untitled Document');

const handleClick = async () => {
backend.putDocument({
...document,
links: [...document.links || [], { verb: 'refersTo', object: relatedTo[0] }]
}).then(() => {
setLastUpdate(document._id);
navigate('#' + document._id);
}).catch(console.error);

backend.getView({view: 'content', id: document._id, options: ['include_docs']})
.then(rows => rows
.filter(x => x.value.isPartOf === document._id)
.map(x => x.id)
.reduce((set, item) => set.includes(item) ? set : [...set, item], [document._id])
.map(x =>
backend.getDocument(x)
.then(chunk => backend.putDocument({
...chunk,
links: [...chunk.links || [], { verb: 'refersTo', object: relatedTo[0] }]
}))
)
)
.then(x => Promise.all(x))
.then(() => {
setLastUpdate(document._id);
navigate('#' + document._id);
})
.catch(console.error);
setShowDocumentList(false);
};

Expand Down

0 comments on commit 5127f17

Please sign in to comment.