[Client] Hoist room-join heal guard lookup out of response switch

This commit is contained in:
Lukas Brübach 2026-09-19 09:55:00 +02:00
parent e1a0e35eda
commit e02706d20e

View file

@ -226,13 +226,13 @@ void TabServer::joinRoomFinished(const Response &r,
{ {
const bool setCurrent = pendingRoomJoins.value(roomId, extraData.toBool()); const bool setCurrent = pendingRoomJoins.value(roomId, extraData.toBool());
pendingRoomJoins.remove(roomId); pendingRoomJoins.remove(roomId);
const bool healedJoin = healedRoomJoins.contains(roomId);
healedRoomJoins.remove(roomId);
switch (r.response_code()) { switch (r.response_code()) {
case Response::RespOk: case Response::RespOk:
healedRoomJoins.remove(roomId);
break; break;
case Response::RespNameNotFound: case Response::RespNameNotFound:
healedRoomJoins.remove(roomId);
if (setCurrent) { if (setCurrent) {
QMessageBox::critical(this, tr("Error"), QMessageBox::critical(this, tr("Error"),
tr("Failed to join the server room: it doesn't exist on the server.")); tr("Failed to join the server room: it doesn't exist on the server."));
@ -240,11 +240,10 @@ void TabServer::joinRoomFinished(const Response &r,
emit roomJoinFailed(roomId); emit roomJoinFailed(roomId);
return; return;
case Response::RespContextError: case Response::RespContextError:
if (healedRoomJoins.contains(roomId)) { if (healedJoin) {
// The rejoin below was already answered and the server still rejects the join, so // The rejoin below was already answered and the server still rejects the join, so
// the stale-membership heal cannot help: surface the error. The guard is released // the stale-membership heal cannot help: surface the error. The guard was already
// again so a later user-initiated join may try a fresh heal. // released above so a later user-initiated join may try a fresh heal.
healedRoomJoins.remove(roomId);
if (setCurrent) { if (setCurrent) {
QMessageBox::critical( QMessageBox::critical(
this, tr("Error"), this, tr("Error"),
@ -264,7 +263,6 @@ void TabServer::joinRoomFinished(const Response &r,
leaveAndRejoinRoom(roomId, setCurrent); leaveAndRejoinRoom(roomId, setCurrent);
return; return;
case Response::RespUserLevelTooLow: case Response::RespUserLevelTooLow:
healedRoomJoins.remove(roomId);
if (setCurrent) { if (setCurrent) {
QMessageBox::critical(this, tr("Error"), QMessageBox::critical(this, tr("Error"),
tr("You do not have the required permission to join this server room.")); tr("You do not have the required permission to join this server room."));
@ -272,7 +270,6 @@ void TabServer::joinRoomFinished(const Response &r,
emit roomJoinFailed(roomId); emit roomJoinFailed(roomId);
return; return;
default: default:
healedRoomJoins.remove(roomId);
if (setCurrent) { if (setCurrent) {
QMessageBox::critical( QMessageBox::critical(
this, tr("Error"), this, tr("Error"),