Fix chat bubble visibility, friends refresh, and DM close
- Chat bubble now hidden on all scenes; MainScreen shows/hides it via Chat.set_bubble_visible() in _ready/_exit_tree - send_friend_request now uses Network.request so _fetch_social() fires on success, making the friends list update immediately after adding - Added DM close button (✕) to each conversation row in the DMs tab; _close_dm removes the channel from local state via Chat.close_dm() 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:
@@ -92,8 +92,7 @@ func _add_overlay() -> void:
|
||||
# ── Auth hooks ────────────────────────────────────────────────────────────────
|
||||
|
||||
func _on_auth_success(_uid: String, _dn: String) -> void:
|
||||
if is_instance_valid(_overlay):
|
||||
_overlay.visible = true
|
||||
# Overlay visibility is controlled by individual scenes via set_bubble_visible().
|
||||
_fetch_social()
|
||||
_fetch_channels()
|
||||
_fetch_notifications()
|
||||
@@ -101,6 +100,13 @@ func _on_auth_success(_uid: String, _dn: String) -> void:
|
||||
_start_message_polling()
|
||||
|
||||
|
||||
## Show or hide the chat bubble overlay. Call from scenes that want chat
|
||||
## (e.g. MainScreen._ready / _exit_tree).
|
||||
func set_bubble_visible(v: bool) -> void:
|
||||
if is_instance_valid(_overlay):
|
||||
_overlay.visible = v
|
||||
|
||||
|
||||
func _clear_state() -> void:
|
||||
if is_instance_valid(_overlay):
|
||||
_overlay.visible = false
|
||||
@@ -147,7 +153,11 @@ func open_dm(recipient_account_id: String) -> void:
|
||||
|
||||
|
||||
func send_friend_request(recipient_id: String) -> void:
|
||||
Network.send("chat.friend_request", { "recipientAccountId": recipient_id })
|
||||
Network.request("chat.friend_request",
|
||||
{ "recipientAccountId": recipient_id },
|
||||
func(_t: String, _p: Variant) -> void: _fetch_social(),
|
||||
func(_c: String, _m: String) -> void: pass
|
||||
)
|
||||
|
||||
|
||||
func respond_friend_request(request_id: String, accept: bool) -> void:
|
||||
@@ -265,6 +275,14 @@ func get_party_channel() -> Dictionary:
|
||||
return c
|
||||
return {}
|
||||
|
||||
|
||||
## Remove a Direct channel from local state (client-side only, no server call).
|
||||
func close_dm(channel_id: String) -> void:
|
||||
channels = channels.filter(func(c: Dictionary) -> bool:
|
||||
return c.get("id", "") != channel_id)
|
||||
messages.erase(channel_id)
|
||||
channels_updated.emit()
|
||||
|
||||
# ── Private helpers ───────────────────────────────────────────────────────────
|
||||
|
||||
func _set_own_presence(status: String) -> void:
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://crug2fpja5h1q
|
||||
@@ -0,0 +1 @@
|
||||
uid://b3kkhkytruoo4
|
||||
@@ -0,0 +1 @@
|
||||
uid://btgg7fge6j3j6
|
||||
@@ -796,6 +796,9 @@ func _refresh_dm_list() -> void:
|
||||
var cid : String = chan.get("id", "")
|
||||
var name : String = chan.get("name", "DM")
|
||||
|
||||
var row := HBoxContainer.new()
|
||||
row.add_theme_constant_override("separation", 0)
|
||||
|
||||
var btn := Button.new()
|
||||
btn.text = name
|
||||
btn.flat = true
|
||||
@@ -803,12 +806,24 @@ func _refresh_dm_list() -> void:
|
||||
btn.custom_minimum_size = Vector2(0, 36)
|
||||
btn.add_theme_font_size_override("font_size", 11)
|
||||
btn.clip_text = true
|
||||
btn.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
|
||||
if cid == _active_dm:
|
||||
_apply_tab_btn_style(btn, true)
|
||||
|
||||
btn.pressed.connect(func() -> void: _select_dm(cid))
|
||||
_dm_conv_list.add_child(btn)
|
||||
row.add_child(btn)
|
||||
|
||||
var close_btn := Button.new()
|
||||
close_btn.text = "✕"
|
||||
close_btn.flat = true
|
||||
close_btn.custom_minimum_size = Vector2(24, 36)
|
||||
close_btn.add_theme_font_size_override("font_size", 10)
|
||||
close_btn.add_theme_color_override("font_color", MUTED_COLOR)
|
||||
close_btn.pressed.connect(func() -> void: _close_dm(cid))
|
||||
row.add_child(close_btn)
|
||||
|
||||
_dm_conv_list.add_child(row)
|
||||
|
||||
|
||||
func _select_dm(channel_id: String) -> void:
|
||||
@@ -823,6 +838,17 @@ func _select_dm(channel_id: String) -> void:
|
||||
_refresh_dm_list()
|
||||
|
||||
|
||||
func _close_dm(channel_id: String) -> void:
|
||||
if _active_dm == channel_id:
|
||||
_active_dm = ""
|
||||
_active_channel = ""
|
||||
_input_bar.visible = false
|
||||
if is_instance_valid(_dm_msg_list):
|
||||
for c in _dm_msg_list.get_children():
|
||||
c.queue_free()
|
||||
Chat.close_dm(channel_id)
|
||||
|
||||
|
||||
func _refresh_dm_messages() -> void:
|
||||
if not is_instance_valid(_dm_msg_list):
|
||||
return
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://blb4o22kdgh5r
|
||||
@@ -19,6 +19,7 @@ extends Control
|
||||
|
||||
func _ready() -> void:
|
||||
welcome_label.text = "Welcome, %s!" % Auth.display_name
|
||||
Chat.set_bubble_visible(true)
|
||||
|
||||
Network.connected.connect(_update_status)
|
||||
Network.disconnected.connect(_update_status)
|
||||
@@ -46,6 +47,7 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
Chat.set_bubble_visible(false)
|
||||
if Network.connected.is_connected(_update_status):
|
||||
Network.connected.disconnect(_update_status)
|
||||
if Network.disconnected.is_connected(_update_status):
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://bmlcf0banjdxd
|
||||
Reference in New Issue
Block a user