From 87e4ca13c556cfdcd734f65fc50f18bb0e3285fa Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Wed, 19 Aug 2026 14:08:29 -0400 Subject: [PATCH] Paint pulled highlights: named colors only + repaint after apply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two rendering gaps once annotations actually synced: - KOReader draws highlight colors from a fixed name set (Blitbuffer.HIGHLIGHT_COLORS); a web hex value (#ffd54f) resolves to nothing useful. The server now serves mapped names, but keep a belt-and-braces guard: only accept plain-name colors, let anything else (hex or unknown) fall back to the device default. - applyServerAnnotations mutated the annotation model but never requested a repaint — ReaderView paints annotations from the model on each redraw, so applied highlights stayed invisible until an unrelated refresh. Mark the reader dialog dirty when anything changed (same call the native highlight flows make). --- main.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.lua b/main.lua index 6802ae7..a212977 100644 --- a/main.lua +++ b/main.lua @@ -1290,7 +1290,14 @@ function Bookhoard:applyServerAnnotations(annotations) entry.drawer = "lighten" entry.text = srv_text if srv_notes ~= "" then entry.note = srv_notes end - if server_entry.color and server_entry.color ~= "" then entry.color = server_entry.color end + -- KOReader renders highlight colors from a fixed name set + -- (Blitbuffer.HIGHLIGHT_COLORS); anything else (e.g. a web + -- hex value slipping through) draws nothing useful, so only + -- keep plain names and let the device default apply. + local srv_color = server_entry.color or "" + if srv_color ~= "" and not srv_color:find("^#") then + entry.color = srv_color + end else if srv_text ~= "" then entry.note = srv_text end -- bookmark label end @@ -1367,6 +1374,11 @@ function Bookhoard:applyServerAnnotations(annotations) if self.ui.saveSettings then self.ui:saveSettings() end + -- ReaderView paints annotations from the model on each repaint; + -- request one so applied highlights appear immediately. + if self.ui.dialog then + UIManager:setDirty(self.ui.dialog, "ui") + end logger.dbg("Bookhoard: annotations updated from server") end end