diff --git a/main.lua b/main.lua index ce6a066..cf7a6e5 100644 --- a/main.lua +++ b/main.lua @@ -1340,15 +1340,22 @@ function Bookhoard:applyServerAnnotations(annotations) entry.drawer = "lighten" entry.text = srv_text if srv_notes ~= "" then entry.note = srv_notes end - -- Match the device's native highlight look exactly: native - -- highlights carry view.highlight.saved_color ("yellow" on - -- color screens); a nil color renders grey (darkenRect). - -- Synced entries still never push this color back (see - -- collectAnnotations) — the web color only changes when the - -- highlight is edited here. - local default_color = (self.ui.view and self.ui.view.highlight - and self.ui.view.highlight.saved_color) or "yellow" - entry.color = default_color + -- Color: the server maps the web color into KOReader's + -- named palette — use it when it arrives as a plain name so + -- synced highlights keep their web color. Anything else + -- (absent, or a raw hex that slipped through) falls back to + -- the device default (view.highlight.saved_color, "yellow" + -- on color screens — nil would render grey via darkenRect). + -- Echoes of applied entries never push this color back + -- (collectAnnotations) unless the user edited them, so the + -- stored web color never drifts. + local srv_color = server_entry.color or "" + if srv_color ~= "" and not srv_color:find("^#") then + entry.color = srv_color + else + entry.color = (self.ui.view and self.ui.view.highlight + and self.ui.view.highlight.saved_color) or "yellow" + end else if srv_text ~= "" then entry.note = srv_text end -- bookmark label end @@ -1363,6 +1370,12 @@ function Bookhoard:applyServerAnnotations(annotations) notes = srv_text, text = srv_notes, } + if has_text then + local srv_color = server_entry.color or "" + if srv_color ~= "" and not srv_color:find("^#") then + entry.color = srv_color + end + end if server_entry.dedup_key and server_entry.dedup_key ~= "" then entry.bookhoard_dedup_key = server_entry.dedup_key end