mirror of
https://github.com/mt-mods/mail.git
synced 2025-07-14 02:11:55 -04:00
Fix duplicating of maillist while changing its name
This commit is contained in:
parent
8f59abdd11
commit
7fb292556c
2 changed files with 9 additions and 11 deletions
16
storage.lua
16
storage.lua
|
@ -148,21 +148,17 @@ function mail.get_maillist_by_name(playername, listname)
|
|||
end
|
||||
|
||||
-- updates or creates a maillist
|
||||
function mail.update_maillist(playername, list)
|
||||
function mail.update_maillist(playername, list, old_list_name)
|
||||
local entry = mail.get_storage_entry(playername)
|
||||
local existing_updated = false
|
||||
for i, existing_list in ipairs(entry.lists) do
|
||||
if existing_list.name == list.name then
|
||||
-- update
|
||||
entry.lists[i] = list
|
||||
existing_updated = true
|
||||
if existing_list.name == old_list_name then
|
||||
-- delete
|
||||
table.remove(entry.lists, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
if not existing_updated then
|
||||
-- insert
|
||||
table.insert(entry.lists, list)
|
||||
end
|
||||
-- insert
|
||||
table.insert(entry.lists, list)
|
||||
mail.set_storage_entry(playername, entry)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue