mirror of
https://github.com/mt-mods/mail.git
synced 2025-03-15 06:01:25 +00:00
Remove unnecessary condition
On (un)select all, both unselect and select start with the same block, then it is better to remove conditions that reduce performance and aren't useful.
This commit is contained in:
parent
f8ace25104
commit
9679251249
1 changed files with 6 additions and 16 deletions
|
@ -254,27 +254,17 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
|
||||
elseif fields.selectall then
|
||||
if formname == "mail:inbox" then
|
||||
if not mail.selected_idxs.inbox[name] then
|
||||
mail.selected_idxs.inbox[name] = {}
|
||||
end
|
||||
if #mail.selected_idxs.inbox[name] >= #getInbox() then -- if selection is full
|
||||
mail.selected_idxs.inbox[name] = {}
|
||||
else
|
||||
mail.selected_idxs.inbox[name] = {} -- reset to avoid duplicates
|
||||
mail.selected_idxs.multipleselection[name] = true
|
||||
mail.selected_idxs.inbox[name] = {} -- reset for select, unselect and not existing
|
||||
mail.selected_idxs.multipleselection[name] = true -- enable as the button were pressed
|
||||
if #mail.selected_idxs.inbox[name] < #getInbox() then -- then populate it if selection isn't full
|
||||
for _, msg in ipairs(getInbox()) do
|
||||
table.insert(mail.selected_idxs.inbox[name], msg.id)
|
||||
end
|
||||
end
|
||||
elseif formname == "mail:sent" then
|
||||
if not mail.selected_idxs.sent[name] then
|
||||
mail.selected_idxs.sent[name] = {}
|
||||
end
|
||||
if #mail.selected_idxs.sent[name] >= #getOutbox() then -- if selection is full
|
||||
mail.selected_idxs.sent[name] = {}
|
||||
else
|
||||
mail.selected_idxs.sent[name] = {} -- reset to avoid duplicates
|
||||
mail.selected_idxs.multipleselection[name] = true
|
||||
mail.selected_idxs.sent[name] = {} -- reset for select, unselect and not existing
|
||||
mail.selected_idxs.multipleselection[name] = true -- enable as the button were pressed
|
||||
if #mail.selected_idxs.sent[name] < #getOutbox() then -- then populate it if selection isn't full
|
||||
for _, msg in ipairs(getOutbox()) do
|
||||
table.insert(mail.selected_idxs.sent[name], msg.id)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue