Skip to content

Commit

Permalink
fix mail.delete_mail (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Jun 6, 2023
1 parent 42db40b commit de07f6b
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,30 +114,27 @@ function mail.delete_mail(playername, msg_ids)
if type(msg_ids) ~= "table" then -- if this is not a table
msg_ids = { msg_ids }
end
if #entry.inbox > 0 then
for i = #entry.inbox, 1, -1 do
for _, deleted_msg in ipairs(msg_ids) do
if entry.inbox[i].id == deleted_msg then
table.remove(entry.inbox, i)
end
for i = #entry.inbox, 1, -1 do
for _, deleted_msg in ipairs(msg_ids) do
if entry.inbox[i].id == deleted_msg then
table.remove(entry.inbox, i)
break
end
end
end
if #entry.outbox > 0 then
for i = #entry.outbox, 1, -1 do
for _, deleted_msg in ipairs(msg_ids) do
if entry.outbox[i].id == deleted_msg then
table.remove(entry.outbox, i)
end
for i = #entry.outbox, 1, -1 do
for _, deleted_msg in ipairs(msg_ids) do
if entry.outbox[i].id == deleted_msg then
table.remove(entry.outbox, i)
break
end
end
end
if #entry.drafts > 0 then
for i = #entry.drafts, 1, -1 do
for _, deleted_msg in ipairs(msg_ids) do
if entry.drafts[i].id == deleted_msg then
table.remove(entry.drafts, i)
end
for i = #entry.drafts, 1, -1 do
for _, deleted_msg in ipairs(msg_ids) do
if entry.drafts[i].id == deleted_msg then
table.remove(entry.drafts, i)
break
end
end
end
Expand Down

0 comments on commit de07f6b

Please sign in to comment.