Use shallow copy instead of original table

This commit is contained in:
SX 2023-04-07 22:09:01 +03:00 committed by GitHub
parent 178345f4fb
commit 2743ad075e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -49,16 +49,17 @@ function mail.sort_messages(messages, sortfield, sortdirection)
and (function(a, b) return a[field] > b[field] end)
or (function(a, b) return a[field] < b[field] end)
end
local result = {unpack(messages)}
if sortfield == "1" then -- for inbox
table.sort(messages, sorter("from", sortdirection))
table.sort(result, sorter("from", sortdirection))
elseif sortfield == "1" then -- for outbox
table.sort(messages, sorter("to", sortdirection))
table.sort(result, sorter("to", sortdirection))
elseif sortfield == "2" then
table.sort(messages, sorter("subject", sortdirection))
table.sort(result, sorter("subject", sortdirection))
else -- default sorting, sortfield == "3"
table.sort(messages, sorter("time", sortdirection))
table.sort(result, sorter("time", sortdirection))
end
return messages
return result
end
function mail.filter_messages(unfiltered_messages, filter)