From d75c0ff65201d00e9cd980a0aeb5d362917a85bb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 4 Sep 2023 09:18:22 +0530 Subject: [PATCH] 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 --- src/pyj/read_book/iframe.pyj | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index 793ff5e1d9..1258c0c346 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -891,19 +891,22 @@ class IframeBoss: self.send_message('annotations', type='edit-highlight-failed', uuid=data.uuid) elif dtype is 'notes-edited': cls = 'crw-has-dot' - crw_ = {v: k for k, v in Object.entries(annot_id_uuid_map)}[data.uuid] - if crw_: - node = last_span_for_crw(crw_) - if node: - if data.has_notes: - node.classList.add(cls) - else: - node.classList.remove(cls) + for qcrw, quuid in Object.entries(annot_id_uuid_map): + if quuid is data.uuid: + node = last_span_for_crw(qcrw) + if node: + if data.has_notes: + node.classList.add(cls) + else: + node.classList.remove(cls) elif dtype is 'remove-highlight': - crw_ = {v: k for k, v in Object.entries(annot_id_uuid_map)}[data.uuid] - if crw_: - unwrap_crw(crw_) - v'delete annot_id_uuid_map[crw_]' + found_highlight_to_remove = False + for qcrw, quuid in Object.entries(annot_id_uuid_map): + if quuid is data.uuid: + found_highlight_to_remove = True + unwrap_crw(qcrw) + v'delete annot_id_uuid_map[crw_]' + if found_highlight_to_remove: # have to remove selection otherwise selection bar does # not hide itself on multiline selections window.getSelection().removeAllRanges()