From addb29a7d2b790b6978e024dc44c6d69b287b4bc Mon Sep 17 00:00:00 2001 From: "zorro.zhang" Date: Mon, 6 Jan 2025 16:36:32 +0800 Subject: [PATCH] ENH: Limit GetPrintTask API in 2Second JIRA: none Change-Id: I285c21bb55cc6783741ec9193cc28396b5586753 --- src/slic3r/GUI/GUI_App.cpp | 2 +- src/slic3r/GUI/Preferences.cpp | 2 +- src/slic3r/GUI/WebViewDialog.cpp | 4 ++-- src/slic3r/GUI/WebViewDialog.hpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index a9191cb31..8607e3e6d 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4394,7 +4394,7 @@ std::string GUI_App::handle_web_request(std::string cmd) else if (command_str.compare("homepage_printhistory_get")==0) { CallAfter([this] { - if (mainframe && mainframe->m_webview) { mainframe->m_webview->ShowUserPrintTask(true); } + if (mainframe && mainframe->m_webview) { mainframe->m_webview->ShowUserPrintTask(true,true); } }); } else if (command_str.compare("homepage_leftmenu_change_width") == 0) { diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index e10a9ed07..1581a1e8b 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -818,7 +818,7 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa if (param == "show_print_history") { auto show_history = app_config->get_bool("show_print_history"); if (show_history == true) { - if (wxGetApp().mainframe && wxGetApp().mainframe->m_webview) { wxGetApp().mainframe->m_webview->ShowUserPrintTask(true); } + if (wxGetApp().mainframe && wxGetApp().mainframe->m_webview) { wxGetApp().mainframe->m_webview->ShowUserPrintTask(true,true); } } else { if (wxGetApp().mainframe && wxGetApp().mainframe->m_webview) { wxGetApp().mainframe->m_webview->ShowUserPrintTask(false); } } diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index 400c6a53c..2c0eedf20 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -1134,7 +1134,7 @@ int WebViewPanel::get_model_mall_detail_url(std::string *url, std::string id) return 0; } -void WebViewPanel::ShowUserPrintTask(bool bShow) +void WebViewPanel::ShowUserPrintTask(bool bShow, bool bForce) { std::string phShow = wxGetApp().app_config->get("app", "show_print_history"); if (bShow && phShow == "false") bShow = false; @@ -1148,7 +1148,7 @@ void WebViewPanel::ShowUserPrintTask(bool bShow) auto now = std::chrono::system_clock::now(); long long TmpMs = std::chrono::duration_cast(now.time_since_epoch()).count(); long long nInterval = TmpMs - PrintTaskMs; - if (nInterval < 2000) return; + if (!bForce && nInterval < 1000 * 60 * 10) return; PrintTaskMs = TmpMs; BBL::TaskQueryParams task_query_params; diff --git a/src/slic3r/GUI/WebViewDialog.hpp b/src/slic3r/GUI/WebViewDialog.hpp index d5525caeb..069b20767 100644 --- a/src/slic3r/GUI/WebViewDialog.hpp +++ b/src/slic3r/GUI/WebViewDialog.hpp @@ -154,7 +154,7 @@ public: std::string m_TaskInfo; bool m_printhistoryfirst; // print history first load wxString m_print_history_LastUrl; - void ShowUserPrintTask(bool bShow); + void ShowUserPrintTask(bool bShow, bool bForce=false); // bool GetJumpUrl(bool login, wxString ticket, wxString targeturl, wxString &finalurl);