extends Window
## Invite link creation dialog: generates and displays an invite token for a room.
@onready var room_label: Label = %RoomLabel
@onready var link_field: LineEdit = %LinkField
@onready var status_label: Label = %StatusLabel
@onready var copy_btn: Button = %CopyBtn
@onready var close_btn: Button = %CloseBtn
var _room_id: String = ""
func _ready() -> void:
close_requested.connect(hide)
close_btn.pressed.connect(hide)
copy_btn.pressed.connect(_on_copy)
copy_btn.disabled = true
func show_for_room(room_id: String, room_title: String) -> void:
_room_id = room_id
room_label.text = "Invite to: %s" % room_title
link_field.text = ""
status_label.text = "Generating invite..."
copy_btn.disabled = true
popup_centered()
KeetService.room_mgr.create_invite(room_id, func(token: String):
if not is_instance_valid(self):
return
if token != "":
link_field.text = token
status_label.text = ""
copy_btn.disabled = false
else:
status_label.text = "Failed to create invite"
)
func _on_copy() -> void:
if link_field.text != "":
DisplayServer.clipboard_set(link_field.text)
status_label.text = "Copied!"