From 1fe77fdaa46a90f2be074fa9707e32e84de7a3fc Mon Sep 17 00:00:00 2001 From: Timo Smit Date: Sat, 4 Feb 2017 14:20:18 +0100 Subject: [PATCH] Also fixed pagination for negative offsets (refs #54) --- luamods/wolfadmin/util/pagination.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/luamods/wolfadmin/util/pagination.lua b/luamods/wolfadmin/util/pagination.lua index f61c501..a27ed27 100644 --- a/luamods/wolfadmin/util/pagination.lua +++ b/luamods/wolfadmin/util/pagination.lua @@ -22,10 +22,14 @@ function pagination.calculate(count, limit, offset) offset = offset or 0 if offset < 0 then - offset = count + offset - end - - if limit + offset > count then + if count < math.abs(offset) then + limit = count + offset = 0 + else + limit = math.min(math.abs(offset), 30) + offset = count + offset + end + elseif limit + offset > count then limit = count % limit end