Fix sorters dropdowns go back to default

This commit is contained in:
Athozus 2023-04-07 19:39:55 +02:00
parent 0d5ed5aca9
commit 49b1f0d400
No known key found for this signature in database
GPG key ID: B50895022E8484BF
3 changed files with 15 additions and 16 deletions

View file

@ -24,15 +24,20 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- then sort them
local sortfield = tostring(fields.sortfield)
local sortdirection = tostring(fields.sortdirection)
if not sortfield or sortfield == "" or sortfield == "0" then
if not fields.sortfield or fields.sortfield == "" then
sortfield = "3"
end
if not sortdirection or sortdirection == "" or sortdirection == "0" then
if not fields.sortdirection or fields.sortdirection == "" then
sortdirection = "1"
end
if not sortfield then
local sortfield = fields.sortfield
end
if not sortdirection then
local sortdirection = fields.sortdirection
end
local messagesInbox = mail.sort_messages(messagesInboxFiltered, sortfield, sortdirection, filter)
local messagesSent = mail.sort_messages(messagesOutboxFiltered, sortfield, sortdirection, filter)

View file

@ -4,15 +4,12 @@ local S = minetest.get_translator("mail")
function mail.show_inbox(name, sortfield, sortdirection, filter)
if not sortfield or sortfield == "" or sortfield == "0" then
sortfield = 3
sortfield = "3"
end
if not sortdirection or sortdirection == "" or sortdirection == "0" then
sortdirection = 1
sortdirection = "1"
end
sortfield = tostring(sortfield)
sortdirection = tostring(sortdirection)
if not filter then
filter = ""
end
@ -34,9 +31,9 @@ function mail.show_inbox(name, sortfield, sortdirection, filter)
button_exit[6,9.5;2.5,0.5;quit;]] .. S("Close") .. [[]
dropdown[0,9.4;2,0.5;sortfield;]] ..
S("From") .. "," .. S("Subject") .. "," .. S("Date") .. [[;]] .. tostring(sortfield) .. [[;1]
S("From") .. "," .. S("Subject") .. "," .. S("Date") .. [[;]] .. sortfield .. [[;true]
dropdown[2.0,9.4;2,0.5;sortdirection;]] ..
S("Ascending") .. "," .. S("Descending") .. [[;]] .. tostring(sortdirection) .. [[;1]
S("Ascending") .. "," .. S("Descending") .. [[;]] .. sortdirection .. [[;true]
field[4.25,9.85;1.4,0.5;filter;]] .. S("Filter") .. [[:;]] .. filter .. [[]
button[5.14,9.52;0.85,0.5;search;Q]

View file

@ -4,15 +4,12 @@ local S = minetest.get_translator("mail")
function mail.show_sent(name, sortfield, sortdirection, filter)
if not sortfield or sortfield == "" or sortfield == "0" then
sortfield = 3
sortfield = "3"
end
if not sortdirection or sortdirection == "" or sortdirection == "0" then
sortdirection = 1
sortdirection = "1"
end
sortfield = tostring(sortfield)
sortdirection = tostring(sortdirection)
if not filter then
filter = ""
end