Fix UI panel overlaps and admin RPC parsing
- Prevent overlap in FragmentCraftPanel by using PanelContainer and Layout Mode 2 - Fix missing Admin Panel data by correctly parsing JSON payload in _rpc helper - Auto-resolve 'social_global' chatroom ID for Admin Panel queries - Untrack .claude and .agent from repository
This commit is contained in:
@@ -301,7 +301,15 @@ func _rpc(rpc_name: String, payload: Dictionary) -> Dictionary:
|
||||
var err: String = str(result.get("message", "Unknown error"))
|
||||
_set_status(err, CLR_STATUS_ERR)
|
||||
return {"error": err}
|
||||
return result.get("data", {})
|
||||
|
||||
var payload_str: String = result.get("payload", "{}")
|
||||
if payload_str.is_empty():
|
||||
payload_str = "{}"
|
||||
|
||||
var parsed = JSON.parse_string(payload_str)
|
||||
if typeof(parsed) == TYPE_DICTIONARY:
|
||||
return parsed
|
||||
return {}
|
||||
|
||||
func _set_status(msg: String, color: Color = CLR_DIM) -> void:
|
||||
status_label.text = msg
|
||||
@@ -1264,12 +1272,30 @@ func _on_wipe_chat() -> void:
|
||||
confirm.popup_centered()
|
||||
confirm.confirmed.connect(func():
|
||||
chat_status_label.text = "Wiping chat..."
|
||||
|
||||
var target_channel_id = ""
|
||||
var lobby = get_tree().get_first_node_in_group("Lobby")
|
||||
if lobby and lobby.has_method("admin_wipe_chat"):
|
||||
lobby.admin_wipe_chat()
|
||||
if lobby and lobby.get("chat") and lobby.chat.get("_chat_channel"):
|
||||
target_channel_id = lobby.chat._chat_channel.id
|
||||
|
||||
if target_channel_id.is_empty():
|
||||
chat_status_label.text = "Error: Not connected to global chat."
|
||||
confirm.queue_free()
|
||||
return
|
||||
|
||||
var payload = JSON.stringify({"channel_id": target_channel_id})
|
||||
var result = await BackendService.admin_clear_global_chat(payload)
|
||||
|
||||
if result.get("success", false):
|
||||
chat_status_label.text = "Chat wiped!"
|
||||
if lobby.has_method("admin_wipe_chat"):
|
||||
# Just update UI locally
|
||||
lobby.chat._chat_messages.clear()
|
||||
lobby.chat._refresh_chat_display()
|
||||
lobby.chat._inject_local_message("[SYSTEM] : Global chat cleared by admin.")
|
||||
else:
|
||||
chat_status_label.text = "Lobby not found — cannot wipe."
|
||||
chat_status_label.text = "Wipe failed: " + str(result.get("message", ""))
|
||||
|
||||
confirm.queue_free()
|
||||
)
|
||||
|
||||
@@ -1286,12 +1312,24 @@ func _on_purge_old_chat() -> void:
|
||||
confirm.popup_centered()
|
||||
confirm.confirmed.connect(func():
|
||||
chat_status_label.text = "Purging old messages..."
|
||||
|
||||
var target_channel_id = ""
|
||||
var lobby = get_tree().get_first_node_in_group("Lobby")
|
||||
if lobby and lobby.has_method("admin_purge_chat"):
|
||||
var deleted: int = await lobby.admin_purge_chat(max_age)
|
||||
chat_status_label.text = "Purged %d old messages." % deleted
|
||||
if lobby and lobby.get("chat") and lobby.chat.get("_chat_channel"):
|
||||
target_channel_id = lobby.chat._chat_channel.id
|
||||
|
||||
if target_channel_id.is_empty():
|
||||
chat_status_label.text = "Error: Not connected to global chat."
|
||||
confirm.queue_free()
|
||||
return
|
||||
|
||||
var result = await BackendService.admin_purge_old_messages(target_channel_id, max_age)
|
||||
if result.has("error"):
|
||||
chat_status_label.text = "Purge failed: " + str(result.get("error", ""))
|
||||
else:
|
||||
chat_status_label.text = "Lobby not found — cannot purge."
|
||||
var deleted: int = result.get("deleted", 0)
|
||||
chat_status_label.text = "Purged %d old messages." % deleted
|
||||
|
||||
confirm.queue_free()
|
||||
)
|
||||
|
||||
@@ -1317,6 +1355,16 @@ func _on_load_chat_messages() -> void:
|
||||
_set_status("Enter a Channel ID first.", CLR_STATUS_ERR)
|
||||
return
|
||||
|
||||
# Auto-resolve "social_global" to the actual Nakama Channel ID if the admin is in the lobby
|
||||
if channel_id == "social_global":
|
||||
var lobby = get_tree().get_first_node_in_group("Lobby")
|
||||
if lobby and lobby.get("chat") and lobby.chat.get("_chat_channel"):
|
||||
channel_id = lobby.chat._chat_channel.id
|
||||
chat_channel_id_edit.text = channel_id # Update UI so admin sees the real ID
|
||||
else:
|
||||
_set_status("Cannot resolve social_global. Join chat first.", CLR_STATUS_ERR)
|
||||
return
|
||||
|
||||
_chat_channel_id = channel_id
|
||||
_chat_cursor = ""
|
||||
_chat_messages_data.clear()
|
||||
|
||||
Reference in New Issue
Block a user