Trim chat messages and don't send any empty ones

This commit is contained in:
Sofia 2026-07-24 21:21:35 +03:00
parent 4512734395
commit bb9ed38278

View File

@ -104,6 +104,7 @@ impl ChatBox {
} }
pub fn on_submit(&mut self, message: GString) { pub fn on_submit(&mut self, message: GString) {
let message = message.to_string().trim().to_owned();
if let Some(line_edit) = &mut self.line_edit { if let Some(line_edit) = &mut self.line_edit {
line_edit.clear(); line_edit.clear();
if self.in_game { if self.in_game {
@ -111,6 +112,9 @@ impl ChatBox {
} }
} }
self.signals().on_closed().emit(); self.signals().on_closed().emit();
if message.is_empty() {
return;
}
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer { if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer {
match peer { match peer {
PeerKind::Client(peer, socket_addr) => { PeerKind::Client(peer, socket_addr) => {