Move the selection list-check loop (fix #108)

This commit is contained in:
Athozus 2023-07-10 19:01:15 +02:00
parent fe9aca40f0
commit fbdaaeec11
No known key found for this signature in database
GPG Key ID: B50895022E8484BF
2 changed files with 30 additions and 30 deletions

View File

@ -13,6 +13,21 @@ function mail.show_inbox(name, sortfieldindex, sortdirection, filter)
local sortfield = ({"from","subject","time"})[sortfieldindex]
local messages = mail.sort_messages(entry.inbox, sortfield, sortdirection == "2", filter)
if mail.selected_idxs.inbox[name] and #mail.selected_idxs.inbox[name] > 0 then
for i, selected_msg in ipairs(mail.selected_idxs.inbox[name]) do
local is_present = false
for _, msg in ipairs(messages) do
if msg.id == selected_msg then
is_present = true
break
end
end
if not is_present then
table.remove(mail.selected_idxs.inbox[name], i)
end
end
end
local trash_tab = ""
if mail.get_setting(name, "trash_move_enable") then
trash_tab = "," .. S("Trash")
@ -116,20 +131,5 @@ function mail.show_inbox(name, sortfieldindex, sortdirection, filter)
formspec[#formspec + 1] = "]label[2.25,4.5;" .. S("No mail") .. "]"
end
if mail.selected_idxs.inbox[name] and #mail.selected_idxs.inbox[name] > 0 then
for i, selected_msg in ipairs(mail.selected_idxs.inbox[name]) do
local is_present = false
for _, msg in ipairs(messages) do
if msg.id == selected_msg then
is_present = true
break
end
end
if not is_present then
table.remove(mail.selected_idxs.inbox[name], i)
end
end
end
minetest.show_formspec(name, "mail:inbox", table.concat(formspec, ""))
end

View File

@ -13,6 +13,21 @@ function mail.show_outbox(name, sortfieldindex, sortdirection, filter)
local sortfield = ({"to","subject","time"})[sortfieldindex]
local messages = mail.sort_messages(entry.outbox, sortfield, sortdirection == "2", filter)
if mail.selected_idxs.outbox[name] and #mail.selected_idxs.outbox[name] > 0 then
for i, selected_msg in ipairs(mail.selected_idxs.outbox[name]) do
local is_present = false
for _, msg in ipairs(messages) do
if msg.id == selected_msg then
is_present = true
break
end
end
if not is_present then
table.remove(mail.selected_idxs.outbox[name], i)
end
end
end
local trash_tab = ""
if mail.get_setting(name, "trash_move_enable") then
trash_tab = "," .. S("Trash")
@ -92,20 +107,5 @@ function mail.show_outbox(name, sortfieldindex, sortdirection, filter)
formspec[#formspec + 1] = "]label[2.25,4.5;" .. S("No mail") .. "]"
end
if mail.selected_idxs.outbox[name] and #mail.selected_idxs.outbox[name] > 0 then
for i, selected_msg in ipairs(mail.selected_idxs.outbox[name]) do
local is_present = false
for _, msg in ipairs(messages) do
if msg.id == selected_msg then
is_present = true
break
end
end
if not is_present then
table.remove(mail.selected_idxs.outbox[name], i)
end
end
end
minetest.show_formspec(name, "mail:outbox", table.concat(formspec, ""))
end