A couple more places that should take into account that there can be multiple annot_ids pointing to an annot uuid in annot_id_uuid_map

This commit is contained in:
Kovid Goyal 2023-09-04 09:18:22 +05:30
parent 8828bc0e61
commit d75c0ff652
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -891,19 +891,22 @@ class IframeBoss:
self.send_message('annotations', type='edit-highlight-failed', uuid=data.uuid) self.send_message('annotations', type='edit-highlight-failed', uuid=data.uuid)
elif dtype is 'notes-edited': elif dtype is 'notes-edited':
cls = 'crw-has-dot' cls = 'crw-has-dot'
crw_ = {v: k for k, v in Object.entries(annot_id_uuid_map)}[data.uuid] for qcrw, quuid in Object.entries(annot_id_uuid_map):
if crw_: if quuid is data.uuid:
node = last_span_for_crw(crw_) node = last_span_for_crw(qcrw)
if node: if node:
if data.has_notes: if data.has_notes:
node.classList.add(cls) node.classList.add(cls)
else: else:
node.classList.remove(cls) node.classList.remove(cls)
elif dtype is 'remove-highlight': elif dtype is 'remove-highlight':
crw_ = {v: k for k, v in Object.entries(annot_id_uuid_map)}[data.uuid] found_highlight_to_remove = False
if crw_: for qcrw, quuid in Object.entries(annot_id_uuid_map):
unwrap_crw(crw_) if quuid is data.uuid:
found_highlight_to_remove = True
unwrap_crw(qcrw)
v'delete annot_id_uuid_map[crw_]' v'delete annot_id_uuid_map[crw_]'
if found_highlight_to_remove:
# have to remove selection otherwise selection bar does # have to remove selection otherwise selection bar does
# not hide itself on multiline selections # not hide itself on multiline selections
window.getSelection().removeAllRanges() window.getSelection().removeAllRanges()