refactor: clearer ClientConnection::showMesssage logic

This commit is contained in:
sithlord48 2025-11-27 09:14:46 -05:00 committed by Nick Bolton
parent 695dc04c00
commit 5287c51957

View file

@ -56,19 +56,27 @@ void ClientConnection::showMessage(const QString &logLine)
{ {
using enum messages::ClientError; using enum messages::ClientError;
Q_EMIT messageShowing(); if (logLine.isEmpty())
return;
const auto address = Settings::value(Settings::Client::RemoteHost).toString(); const auto address = Settings::value(Settings::Client::RemoteHost).toString();
auto error = NoError;
if (logLine.contains("server already has a connected client with our name")) { 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()) { } else if (QHostAddress a(address); a.isNull()) {
qDebug("ip not detected, showing hostname error"); qDebug("ip not detected, showing hostname error");
m_deps->showError(m_pParent, HostnameError, address); error = HostnameError;
} else { } else {
qDebug("ip detected, showing generic error"); 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 } // namespace deskflow::gui