feat: 2.3.1
This commit is contained in:
@@ -90,7 +90,52 @@ func delete_mail(mail_id: String) -> bool:
|
||||
|
||||
func mark_as_read(mail_id: String) -> void:
|
||||
if mail_id in read_ids: return
|
||||
# Since there's no specific RPC for just marking as read, we can just do a claim with 0 rewards if needed,
|
||||
# or add an RPC for it. For now we just let claim or delete handle the server-side state.
|
||||
# Let's add an empty claim or just handle it purely local until claimed/deleted if it has no rewards.
|
||||
pass
|
||||
read_ids.append(mail_id)
|
||||
_update_unread_count()
|
||||
# Persist read state to server via delete_mail RPC pattern (just saves state)
|
||||
_save_inbox_state()
|
||||
|
||||
func _save_inbox_state() -> void:
|
||||
if not NakamaManager.session: return
|
||||
var state_payload = {
|
||||
"claimed_ids": claimed_ids,
|
||||
"deleted_ids": [],
|
||||
"read_ids": read_ids
|
||||
}
|
||||
# We use storage write via a lightweight RPC or direct storage
|
||||
var r = await NakamaManager.client.rpc_async(
|
||||
NakamaManager.session, "save_mail_state",
|
||||
JSON.stringify(state_payload)
|
||||
)
|
||||
if r.is_exception():
|
||||
push_warning("[MailManager] Could not save mail state: " + r.get_exception().message)
|
||||
|
||||
func read_all_and_claim_all() -> void:
|
||||
"""Mark all mails as read and claim all unclaimed rewards."""
|
||||
if mails.is_empty(): return
|
||||
|
||||
# Mark all as read
|
||||
for mail in mails:
|
||||
var mid = mail.get("id", "")
|
||||
if mid not in read_ids:
|
||||
read_ids.append(mid)
|
||||
|
||||
# Claim all unclaimed rewards
|
||||
var to_claim: Array = []
|
||||
for mail in mails:
|
||||
var mid = mail.get("id", "")
|
||||
if mid in claimed_ids: continue
|
||||
var rewards = mail.get("rewards", [])
|
||||
var has_rewards = false
|
||||
if typeof(rewards) == TYPE_DICTIONARY:
|
||||
has_rewards = rewards.get("star", 0) > 0 or rewards.get("gold", 0) > 0
|
||||
elif typeof(rewards) == TYPE_ARRAY:
|
||||
has_rewards = rewards.size() > 0
|
||||
if has_rewards:
|
||||
to_claim.append(mid)
|
||||
|
||||
for mid in to_claim:
|
||||
await claim_reward(mid)
|
||||
|
||||
_update_unread_count()
|
||||
mail_updated.emit()
|
||||
|
||||
Reference in New Issue
Block a user