Perform reload on Connect tab when shown.

This commit is contained in:
David Kocik 2025-01-16 17:41:07 +01:00 committed by Lukas Matena
parent 003b0ad6e4
commit 464a3b8c5e
2 changed files with 12 additions and 0 deletions

View File

@ -642,6 +642,7 @@ void ConnectWebViewPanel::late_create()
void ConnectWebViewPanel::on_user_token(UserAccountSuccessEvent& e)
{
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__;
e.Skip();
if (!m_browser) {
return;
@ -661,6 +662,7 @@ ConnectWebViewPanel::~ConnectWebViewPanel()
wxString ConnectWebViewPanel::get_login_script(bool refresh)
{
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__;
Plater* plater = wxGetApp().plater();
const std::string& access_token = plater->get_user_account()->get_access_token();
assert(!access_token.empty());
@ -811,6 +813,7 @@ void ConnectWebViewPanel::on_page_will_load()
if (!m_browser) {
return;
}
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__;
auto javascript = get_login_script(false);
BOOST_LOG_TRIVIAL(debug) << "RunScript " << javascript << "\n";
m_browser->AddUserScript(javascript);
@ -860,6 +863,7 @@ void ConnectWebViewPanel::on_navigation_request(wxWebViewEvent &evt)
void ConnectWebViewPanel::on_connect_action_error(const std::string &message_data)
{
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__;
ConnectRequestHandler::on_connect_action_error(message_data);
// TODO: make this more user friendly (and make sure only once opened if multiple errors happen)
// MessageDialog dialog(
@ -874,6 +878,7 @@ void ConnectWebViewPanel::on_connect_action_error(const std::string &message_dat
void ConnectWebViewPanel::on_reload_event(const std::string& message_data)
{
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__;
// Event from our error page button or keyboard shortcut
m_styles_defined = false;
try {
@ -892,6 +897,12 @@ void ConnectWebViewPanel::on_reload_event(const std::string& message_data)
}
}
void ConnectWebViewPanel::after_on_show(wxShowEvent& evt)
{
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__;
run_script("window.location.reload();");
}
void ConnectWebViewPanel::logout()
{
if (!m_browser || m_do_late_webview_create) {

View File

@ -148,6 +148,7 @@ protected:
void on_connect_action_close_dialog(const std::string& message_data) override {assert(false);}
void on_user_token(UserAccountSuccessEvent& e);
void define_css() override;
void after_on_show(wxShowEvent& evt) override;
private:
static wxString get_login_script(bool refresh);
static wxString get_logout_script();