Add friends, DMs, presence, block, and party chat
- Fix social response key mismatch (incomingRequests, blocked) - Fix DmOpenResponse to return full ChatChannelDto so client can add the channel without a separate fetch - Add Party channel type to ChatChannelType enum - Add PartyInviteHandler, PartyInviteRespondHandler, PartyLeaveHandler with IClientPush invite notification to the invitee - Add party tab to chat overlay (action bar, messages, Leave button) - Wire Invite to Party in both player and friend context menus - Show accept/decline popup dialog on incoming party invite push Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -30,6 +30,13 @@ signal presence_updated
|
||||
## Emitted after notifications array changes.
|
||||
signal notifications_updated
|
||||
|
||||
## Emitted when the party channel is joined, left, or updated.
|
||||
signal party_updated
|
||||
|
||||
## Emitted when a remote player invites the local player to their party.
|
||||
## channel_id: the Party channel to accept into; inviter_name: display name of sender.
|
||||
signal party_invite_received(channel_id: String, inviter_name: String)
|
||||
|
||||
# ── State ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
## Array[Dictionary] — ChatChannelDto {id, name, channelType, createdAt}
|
||||
@@ -108,6 +115,7 @@ func _clear_state() -> void:
|
||||
_message_poll_in_flight.clear()
|
||||
channels_updated.emit()
|
||||
social_updated.emit()
|
||||
party_updated.emit()
|
||||
|
||||
# ── Public API ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -189,6 +197,36 @@ func fetch_presence(account_ids: Array) -> void:
|
||||
)
|
||||
|
||||
|
||||
## Invite a player to the caller's party (creates the party channel if needed).
|
||||
func invite_to_party(account_id: String) -> void:
|
||||
Network.request(
|
||||
"chat.party.invite",
|
||||
{ "inviteeAccountId": account_id },
|
||||
_on_party_invite_sent_success,
|
||||
_noop_error
|
||||
)
|
||||
|
||||
|
||||
## Accept or decline an incoming party invite.
|
||||
func respond_party_invite(channel_id: String, accept: bool) -> void:
|
||||
Network.request(
|
||||
"chat.party.invite_respond",
|
||||
{ "channelId": channel_id, "accept": accept },
|
||||
_on_party_invite_respond_success,
|
||||
_noop_error
|
||||
)
|
||||
|
||||
|
||||
## Leave the current party channel.
|
||||
func leave_party() -> void:
|
||||
Network.request(
|
||||
"chat.party.leave",
|
||||
{},
|
||||
_on_party_leave_success,
|
||||
_noop_error
|
||||
)
|
||||
|
||||
|
||||
func mark_notifications_read(ids: Array) -> void:
|
||||
if ids.is_empty():
|
||||
return
|
||||
@@ -219,6 +257,14 @@ func get_dm_channels() -> Array:
|
||||
func(c: Dictionary) -> bool: return c.get("channelType", "") == "Direct"
|
||||
)
|
||||
|
||||
|
||||
## Returns the caller's current Party channel, or {} if not in one.
|
||||
func get_party_channel() -> Dictionary:
|
||||
for c: Dictionary in channels:
|
||||
if c.get("channelType", "") == "Party":
|
||||
return c
|
||||
return {}
|
||||
|
||||
# ── Private helpers ───────────────────────────────────────────────────────────
|
||||
|
||||
func _set_own_presence(status: String) -> void:
|
||||
@@ -351,8 +397,8 @@ func _on_fetch_presence_success(_t: String, p: Variant) -> void:
|
||||
func _on_fetch_social_success(_t: String, p: Variant) -> void:
|
||||
var d := p as Dictionary
|
||||
friends = d.get("friends", [])
|
||||
pending_requests = d.get("pendingRequests", [])
|
||||
blocked_users = d.get("blockedUsers", [])
|
||||
pending_requests = d.get("incomingRequests", [])
|
||||
blocked_users = d.get("blocked", [])
|
||||
social_updated.emit()
|
||||
var ids: Array = friends.map(func(f: Dictionary) -> String:
|
||||
return f.get("accountId", ""))
|
||||
@@ -369,6 +415,49 @@ func _on_fetch_notifications_success(_t: String, p: Variant) -> void:
|
||||
notifications_updated.emit()
|
||||
|
||||
|
||||
func _on_party_invite_sent_success(_t: String, p: Variant) -> void:
|
||||
var chan: Dictionary = (p as Dictionary).get("channel", {})
|
||||
if not chan.is_empty():
|
||||
_upsert_channel(chan)
|
||||
party_updated.emit()
|
||||
channels_updated.emit()
|
||||
|
||||
|
||||
func _on_party_invite_respond_success(_t: String, p: Variant) -> void:
|
||||
var d := p as Dictionary
|
||||
if not d.get("accepted", false):
|
||||
return
|
||||
var chan: Dictionary = d.get("channel", {})
|
||||
if not chan.is_empty():
|
||||
_upsert_channel(chan)
|
||||
party_updated.emit()
|
||||
channels_updated.emit()
|
||||
|
||||
|
||||
func _on_party_leave_success(_t: String, _p: Variant) -> void:
|
||||
channels = channels.filter(func(c: Dictionary) -> bool:
|
||||
return c.get("channelType", "") != "Party")
|
||||
messages.erase(_get_party_channel_id())
|
||||
party_updated.emit()
|
||||
channels_updated.emit()
|
||||
|
||||
|
||||
func _get_party_channel_id() -> String:
|
||||
for c: Dictionary in channels:
|
||||
if c.get("channelType", "") == "Party":
|
||||
return c.get("id", "")
|
||||
return ""
|
||||
|
||||
|
||||
func _upsert_channel(chan: Dictionary) -> void:
|
||||
var cid: String = chan.get("id", "")
|
||||
for i in channels.size():
|
||||
if (channels[i] as Dictionary).get("id", "") == cid:
|
||||
channels[i] = chan
|
||||
return
|
||||
channels.push_front(chan)
|
||||
|
||||
|
||||
func _noop_error(_c: String, _m: String) -> void:
|
||||
pass
|
||||
|
||||
@@ -391,3 +480,10 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
if not notif.is_empty():
|
||||
notifications.push_front(notif)
|
||||
notifications_updated.emit()
|
||||
|
||||
"chat.party_invite.push":
|
||||
var d := payload as Dictionary
|
||||
var cid : String = d.get("channelId", "")
|
||||
var inviter : String = d.get("inviterName", "Someone")
|
||||
if not cid.is_empty():
|
||||
party_invite_received.emit(cid, inviter)
|
||||
|
||||
Reference in New Issue
Block a user