Skip to content

Commit

Permalink
Message reply fixes (#78)
Browse files Browse the repository at this point in the history
* Fix reply buttons in message list

* Give a default boxtab value (fix trivial issues)
  • Loading branch information
Athozus authored Apr 26, 2023
1 parent 1a84c66 commit 7449aac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ui/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,28 +193,28 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
mail.show_mail_menu(name, sortfieldindex, sortdirection, filter)

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]])
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]])
mail.reply(name, message)
end

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]])
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]])
mail.replyall(name, message)
end

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]])
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]])
mail.forward(name, message)
end
Expand Down
3 changes: 3 additions & 0 deletions ui/mail.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

function mail.show_mail_menu(playername, sortfield, sortdirection, filter)
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
mail.show_inbox(playername, sortfield, sortdirection, filter)
elseif index == 2 then
Expand Down

0 comments on commit 7449aac

Please sign in to comment.