Message reply fixes (#78)

* Fix reply buttons in message list

* Give a default boxtab value (fix trivial issues)
This commit is contained in:
Athozus 2023-04-26 12:11:27 +02:00 committed by GitHub
parent 1a84c66346
commit 7449aaca52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -193,28 +193,28 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
mail.show_mail_menu(name, sortfieldindex, sortdirection, filter) mail.show_mail_menu(name, sortfieldindex, sortdirection, filter)
elseif fields.reply then elseif fields.reply then
if formname == "mail:inbox" and mail.selected_idxs.inbox[name] then if formname == "mail:inbox" and mail.selected_idxs.inbox[name] and #mail.selected_idxs.inbox[name] > 0 then
local message = mail.get_message(name, mail.selected_idxs.inbox[name][#mail.selected_idxs.inbox[name]]) local message = mail.get_message(name, mail.selected_idxs.inbox[name][#mail.selected_idxs.inbox[name]])
mail.reply(name, message) mail.reply(name, message)
elseif formname == "mail:sent" and mail.selected_idxs.sent[name] then elseif formname == "mail:sent" and mail.selected_idxs.sent[name] and #mail.selected_idxs.sent[name] > 0 then
local message = mail.get_message(name, mail.selected_idxs.sent[name][#mail.selected_idxs.sent[name]]) local message = mail.get_message(name, mail.selected_idxs.sent[name][#mail.selected_idxs.sent[name]])
mail.reply(name, message) mail.reply(name, message)
end end
elseif fields.replyall then elseif fields.replyall then
if formname == "mail:inbox" and mail.selected_idxs.inbox[name] then if formname == "mail:inbox" and mail.selected_idxs.inbox[name] and #mail.selected_idxs.inbox[name] > 0 then
local message = mail.get_message(name, mail.selected_idxs.inbox[name][#mail.selected_idxs.inbox[name]]) local message = mail.get_message(name, mail.selected_idxs.inbox[name][#mail.selected_idxs.inbox[name]])
mail.replyall(name, message) mail.replyall(name, message)
elseif formname == "mail:sent" and mail.selected_idxs.sent[name] then elseif formname == "mail:sent" and mail.selected_idxs.sent[name] and #mail.selected_idxs.sent[name] > 0 then
local message = mail.get_message(name, mail.selected_idxs.sent[name][#mail.selected_idxs.sent[name]]) local message = mail.get_message(name, mail.selected_idxs.sent[name][#mail.selected_idxs.sent[name]])
mail.replyall(name, message) mail.replyall(name, message)
end end
elseif fields.forward then elseif fields.forward then
if formname == "mail:inbox" and mail.selected_idxs.inbox[name] then if formname == "mail:inbox" and mail.selected_idxs.inbox[name] and #mail.selected_idxs.inbox[name] > 0 then
local message = mail.get_message(name, mail.selected_idxs.inbox[name][#mail.selected_idxs.inbox[name]]) local message = mail.get_message(name, mail.selected_idxs.inbox[name][#mail.selected_idxs.inbox[name]])
mail.forward(name, message) mail.forward(name, message)
elseif formname == "mail:sent" and mail.selected_idxs.sent[name] then elseif formname == "mail:sent" and mail.selected_idxs.sent[name] and #mail.selected_idxs.sent[name] > 0 then
local message = mail.get_message(name, mail.selected_idxs.sent[name][#mail.selected_idxs.sent[name]]) local message = mail.get_message(name, mail.selected_idxs.sent[name][#mail.selected_idxs.sent[name]])
mail.forward(name, message) mail.forward(name, message)
end end

View File

@ -2,6 +2,9 @@
function mail.show_mail_menu(playername, sortfield, sortdirection, filter) function mail.show_mail_menu(playername, sortfield, sortdirection, filter)
local index = mail.selected_idxs.boxtab[playername] or 1 local index = mail.selected_idxs.boxtab[playername] or 1
if not mail.selected_idxs.boxtab[playername] then
mail.selected_idxs.boxtab[playername] = 1
end
if index == 1 then if index == 1 then
mail.show_inbox(playername, sortfield, sortdirection, filter) mail.show_inbox(playername, sortfield, sortdirection, filter)
elseif index == 2 then elseif index == 2 then