[fix] fix connection error when reinput password

This commit is contained in:
dijunkun
2025-04-09 17:17:30 +08:00
parent cf078be53f
commit f48085c69a
2 changed files with 11 additions and 11 deletions

View File

@@ -4,7 +4,7 @@
#include "render.h"
int Render::ConnectionStatusWindow(
std::shared_ptr<SubStreamWindowProperties> &properties) {
std::shared_ptr<SubStreamWindowProperties> &props) {
if (show_connection_status_window_) {
const ImGuiViewport *viewport = ImGui::GetMainViewport();
@@ -34,11 +34,11 @@ int Render::ConnectionStatusWindow(
ImGui::SetWindowFontScale(0.5f);
std::string text;
if (ConnectionStatus::Connecting == properties->connection_status_) {
if (ConnectionStatus::Connecting == props->connection_status_) {
text = localization::p2p_connecting[localization_language_index_];
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
} else if (ConnectionStatus::Connected == properties->connection_status_) {
} else if (ConnectionStatus::Connected == props->connection_status_) {
text = localization::p2p_connected[localization_language_index_];
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
@@ -49,8 +49,7 @@ int Render::ConnectionStatusWindow(
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
show_connection_status_window_ = false;
}
} else if (ConnectionStatus::Disconnected ==
properties->connection_status_) {
} else if (ConnectionStatus::Disconnected == props->connection_status_) {
text = localization::p2p_disconnected[localization_language_index_];
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
@@ -61,7 +60,7 @@ int Render::ConnectionStatusWindow(
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
show_connection_status_window_ = false;
}
} else if (ConnectionStatus::Failed == properties->connection_status_) {
} else if (ConnectionStatus::Failed == props->connection_status_) {
text = localization::p2p_failed[localization_language_index_];
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
@@ -72,7 +71,7 @@ int Render::ConnectionStatusWindow(
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
show_connection_status_window_ = false;
}
} else if (ConnectionStatus::Closed == properties->connection_status_) {
} else if (ConnectionStatus::Closed == props->connection_status_) {
text = localization::p2p_closed[localization_language_index_];
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
@@ -84,7 +83,7 @@ int Render::ConnectionStatusWindow(
show_connection_status_window_ = false;
}
} else if (ConnectionStatus::IncorrectPassword ==
properties->connection_status_) {
props->connection_status_) {
if (!password_validating_) {
if (password_validating_time_ == 1) {
text = localization::input_password[localization_language_index_];
@@ -118,7 +117,7 @@ int Render::ConnectionStatusWindow(
ImGui::Checkbox(
localization::remember_password[localization_language_index_]
.c_str(),
&(properties->remember_password_));
&(props->remember_password_));
ImGui::SetWindowFontScale(0.5f);
ImGui::PopStyleVar();
@@ -130,7 +129,7 @@ int Render::ConnectionStatusWindow(
ImGui::IsKeyPressed(ImGuiKey_Enter)) {
show_connection_status_window_ = true;
password_validating_ = true;
rejoin_ = true;
props->rejoin_ = true;
focus_on_input_widget_ = true;
}
@@ -149,7 +148,7 @@ int Render::ConnectionStatusWindow(
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
}
} else if (ConnectionStatus::NoSuchTransmissionId ==
properties->connection_status_) {
props->connection_status_) {
text = localization::no_such_id[localization_language_index_];
ImGui::SetCursorPosX(connection_status_window_width_ * 3 / 7);
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);

View File

@@ -371,6 +371,7 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char *user_id,
render->password_validating_ = false;
render->password_validating_time_++;
if (render->connect_button_pressed_) {
render->connect_button_pressed_ = false;
props->connection_established_ = false;
render->connect_button_label_ =
render->connect_button_pressed_