mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-03 19:50:40 +08:00
Fix of sending refreshed token to Connect
Improved timeout logic
This commit is contained in:
parent
5ba8f21c77
commit
0503733694
@ -553,9 +553,10 @@ void UserAccountCommunication::set_refresh_time(int seconds)
|
||||
{
|
||||
assert(m_token_timer);
|
||||
m_token_timer->Stop();
|
||||
const auto prior_expiration_secs = 5 * 60;
|
||||
int milliseconds = std::max((seconds - prior_expiration_secs) * 1000, 50000);
|
||||
const auto prior_expiration_secs = std::max(seconds / 24, 10);
|
||||
int milliseconds = std::max((seconds - prior_expiration_secs) * 1000, 1000);
|
||||
m_next_token_refresh_at = std::time(nullptr) + milliseconds / 1000;
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << " " << milliseconds / 1000;
|
||||
m_token_timer->StartOnce(milliseconds);
|
||||
}
|
||||
|
||||
|
@ -576,12 +576,13 @@ ConnectWebViewPanel::ConnectWebViewPanel(wxWindow* parent)
|
||||
{
|
||||
auto* plater = wxGetApp().plater();
|
||||
plater->Bind(EVT_UA_LOGGEDOUT, &ConnectWebViewPanel::on_user_logged_out, this);
|
||||
plater->Bind(EVT_UA_ID_USER_SUCCESS, &ConnectWebViewPanel::on_user_token, this);
|
||||
}
|
||||
|
||||
void ConnectWebViewPanel::late_create()
|
||||
{
|
||||
WebViewPanel::late_create();
|
||||
if (!m_browser) {
|
||||
if (!m_browser) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -595,6 +596,21 @@ void ConnectWebViewPanel::late_create()
|
||||
resend_config();
|
||||
}
|
||||
|
||||
void ConnectWebViewPanel::on_user_token(UserAccountSuccessEvent& e)
|
||||
{
|
||||
e.Skip();
|
||||
if (!m_browser) {
|
||||
return;
|
||||
}
|
||||
auto access_token = wxGetApp().plater()->get_user_account()->get_access_token();
|
||||
assert(!access_token.empty());
|
||||
|
||||
wxString javascript = get_login_script(true);
|
||||
BOOST_LOG_TRIVIAL(debug) << "RunScript " << javascript << "\n";
|
||||
m_browser->RunScriptAsync(javascript);
|
||||
resend_config();
|
||||
}
|
||||
|
||||
ConnectWebViewPanel::~ConnectWebViewPanel()
|
||||
{
|
||||
}
|
||||
|
@ -142,6 +142,7 @@ protected:
|
||||
void on_connect_action_error(const std::string &message_data) override;
|
||||
void on_reload_event(const std::string& message_data) override;
|
||||
void on_connect_action_close_dialog(const std::string& message_data) override {assert(true);}
|
||||
void on_user_token(UserAccountSuccessEvent& e);
|
||||
private:
|
||||
static wxString get_login_script(bool refresh);
|
||||
static wxString get_logout_script();
|
||||
|
Loading…
x
Reference in New Issue
Block a user