Optimize performance of the inbox

Moves the `mail.get_setting(name, "mute_list")` call out of the message loop. Previously, this is called repeated, causing disastrous lag when using mail with beerchat.
This commit is contained in:
1F616EMO 2024-08-06 08:09:00 +08:00 committed by Athozus
parent 036d37695a
commit 4cd06c5f5f

View File

@ -77,6 +77,7 @@ function mail.show_inbox(name, sortfieldindex, sortdirection, filter)
local unread_color_enable = mail.get_setting(name, "unreadcolorenable")
local cc_color_enable = mail.get_setting(name, "cccolorenable")
local mute_list = mail.get_setting(name, "mute_list")
if #messages > 0 then
for _, message in ipairs(messages) do
@ -103,7 +104,7 @@ function mail.show_inbox(name, sortfieldindex, sortdirection, filter)
if message.spam then
table.insert(displayed_color, "warning")
end
if table.indexof(mail.get_setting(name, "mute_list"), message.from) >= 1 then
if table.indexof(mute_list, message.from) >= 1 then
table.insert(displayed_color, "muted")
end
formspec[#formspec + 1] = "," .. mail.get_color(displayed_color)