From cea25ef4659c933c401b81df211125f05c46b2d0 Mon Sep 17 00:00:00 2001 From: Bailey Jennings Date: Thu, 14 May 2026 14:37:30 -0400 Subject: [PATCH] fix(koplugin): omit empty note field when syncing annotations (#4161) When syncing highlights between Readest and KOReader, the `note` field was forced to an empty string (`""`) for annotations and bookmarks without notes. KOReader's native annotations omit the field entirely when no note exists, so the empty string caused KOReader to treat every synced highlight as having a (blank) note. Apply the same omission in both push and pull directions. Co-authored-by: Claude --- apps/readest.koplugin/readest_syncannotations.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/readest.koplugin/readest_syncannotations.lua b/apps/readest.koplugin/readest_syncannotations.lua index 76a885f6..db08ac7b 100644 --- a/apps/readest.koplugin/readest_syncannotations.lua +++ b/apps/readest.koplugin/readest_syncannotations.lua @@ -92,6 +92,8 @@ function SyncAnnotations:getAnnotations(ui, settings, book_hash, meta_hash, full end local id = item.id or self:generateNoteId(book_hash, "annotation", tostring(pos0), pos1 and tostring(pos1)) + local note_text = item.note + if note_text == "" then note_text = nil end table.insert(notes, { bookHash = book_hash, metaHash = meta_hash, @@ -100,7 +102,7 @@ function SyncAnnotations:getAnnotations(ui, settings, book_hash, meta_hash, full xpointer0 = tostring(pos0), xpointer1 = pos1 and tostring(pos1) or nil, text = item.text or "", - note = item.note or "", + note = note_text, style = style, color = KO_TO_READEST_COLOR[item.color or "yellow"], page = item.pageno, @@ -111,6 +113,8 @@ function SyncAnnotations:getAnnotations(ui, settings, book_hash, meta_hash, full -- Bookmark: no drawer, position in page field (xpointer string) local page_xp = item.page local id = item.id or self:generateNoteId(book_hash, "bookmark", page_xp) + local note_text = item.note + if note_text == "" then note_text = nil end table.insert(notes, { bookHash = book_hash, metaHash = meta_hash, @@ -118,7 +122,7 @@ function SyncAnnotations:getAnnotations(ui, settings, book_hash, meta_hash, full type = "bookmark", xpointer0 = page_xp, text = item.text or "", - note = item.note or "", + note = note_text, page = item.pageno, createdAt = self:parseDatetimeToMs(item.datetime), updatedAt = updated_at, @@ -305,6 +309,9 @@ function SyncAnnotations:pull(ui, settings, client, book_hash, meta_hash, dialog local chapter = ui.toc and ui.toc:getTocTitleByPage(xp0) or nil if chapter == "" then chapter = nil end + local note_text = note.note + if note_text == "" then note_text = nil end + if note_type == "bookmark" then if existing_bookmarks[xp0] then goto continue end @@ -312,7 +319,7 @@ function SyncAnnotations:pull(ui, settings, client, book_hash, meta_hash, dialog id = note.id, page = xp0, text = note.text or "", - note = note.note or "", + note = note_text, chapter = chapter, pageno = pageno, datetime = datetime_str, @@ -337,7 +344,7 @@ function SyncAnnotations:pull(ui, settings, client, book_hash, meta_hash, dialog pos1 = xp1 or xp0, page = xp0, text = note.text or "", - note = note.note or "", + note = note_text, drawer = drawer, color = READEST_TO_KO_COLOR[note.color] or "yellow", chapter = chapter,