Fixes multiple mentions issue (#929)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2022-02-04 16:03:45 +07:00 committed by GitHub
parent db52006a9d
commit 9f9650f938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,9 +38,13 @@ function extractBacklinks (backlinkId: Ref<Doc>, backlinkClass: Ref<Class<Doc>>,
nds.forEach((kid) => { nds.forEach((kid) => {
if (kid.nodeType === Node.ELEMENT_NODE && (kid as HTMLElement).localName === 'span') { if (kid.nodeType === Node.ELEMENT_NODE && (kid as HTMLElement).localName === 'span') {
const el = kid as HTMLElement const el = kid as HTMLElement
const ato = el.getAttribute('data-id') as Ref<Doc>
const atoClass = el.getAttribute('data-objectclass') as Ref<Class<Doc>>
const e = result.find(e => e.attachedTo === ato && e.attachedToClass === atoClass)
if (e === undefined) {
result.push({ result.push({
attachedTo: el.getAttribute('data-id') as Ref<Doc>, attachedTo: ato,
attachedToClass: el.getAttribute('data-objectclass') as Ref<Class<Doc>>, attachedToClass: atoClass,
collection: 'backlinks', collection: 'backlinks',
backlinkId, backlinkId,
backlinkClass, backlinkClass,
@ -48,6 +52,7 @@ function extractBacklinks (backlinkId: Ref<Doc>, backlinkClass: Ref<Class<Doc>>,
attachedDocId attachedDocId
}) })
} }
}
nodes.push(kid.childNodes) nodes.push(kid.childNodes)
}) })
} }