From b987aa1d187b94314b567698f4aa8a98f2ece359 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Fri, 5 Apr 2024 09:50:10 +0300 Subject: [PATCH] Update readerannotation.lua --- frontend/apps/reader/modules/readerannotation.lua | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/frontend/apps/reader/modules/readerannotation.lua b/frontend/apps/reader/modules/readerannotation.lua index 47126e86b..8b2be89c7 100644 --- a/frontend/apps/reader/modules/readerannotation.lua +++ b/frontend/apps/reader/modules/readerannotation.lua @@ -4,7 +4,7 @@ local _ = require("gettext") local T = require("ffi/util").template local ReaderAnnotation = WidgetContainer:extend{ - annotations = nil, + annotations = nil, -- array sorted by annotation position order, ascending } -- build, read, save @@ -81,13 +81,8 @@ function ReaderAnnotation:getAnnotationsFromBookmarksHighlights(bookmarks, highl table.insert(annotations, self:buildAnnotation(bookmarks[i], highlights, init)) end if #annotations > 1 then - local sort_func = function(a, b) - if self.ui.rolling then - return self:isItemInPositionOrderRolling(a, b) - else - return self:isItemInPositionOrderPaging(a, b) - end - end + local sort_func = self.ui.rolling and function(a, b) return self:isItemInPositionOrderRolling(a, b) end + or function(a, b) return self:isItemInPositionOrderPaging(a, b) end table.sort(annotations, sort_func) end return annotations