From 5287c5195737cd0c6f2c26af41389bf36cef28ed Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Thu, 27 Nov 2025 09:14:46 -0500 Subject: [PATCH] refactor: clearer ClientConnection::showMesssage logic --- src/lib/gui/core/ClientConnection.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lib/gui/core/ClientConnection.cpp b/src/lib/gui/core/ClientConnection.cpp index b07f9fcad..bad0a7c4c 100644 --- a/src/lib/gui/core/ClientConnection.cpp +++ b/src/lib/gui/core/ClientConnection.cpp @@ -56,19 +56,27 @@ void ClientConnection::showMessage(const QString &logLine) { using enum messages::ClientError; - Q_EMIT messageShowing(); + if (logLine.isEmpty()) + return; const auto address = Settings::value(Settings::Client::RemoteHost).toString(); + auto error = NoError; if (logLine.contains("server already has a connected client with our name")) { - m_deps->showError(m_pParent, AlreadyConnected, address); + error = AlreadyConnected; } else if (QHostAddress a(address); a.isNull()) { qDebug("ip not detected, showing hostname error"); - m_deps->showError(m_pParent, HostnameError, address); + error = HostnameError; } else { qDebug("ip detected, showing generic error"); - m_deps->showError(m_pParent, GenericError, address); + error = GenericError; } + + if (error == NoError) + return; + + Q_EMIT messageShowing(); + m_deps->showError(m_pParent, error, address); } } // namespace deskflow::gui