remove staff_pick_switch

This commit is contained in:
SoftFever 2023-11-03 00:12:33 +08:00
parent 70c5178e50
commit 4fe80bcbc5
4 changed files with 71 additions and 71 deletions

View file

@ -312,9 +312,9 @@ void AppConfig::set_defaults()
set("max_recent_count", "18");
}
if (get("staff_pick_switch").empty()) {
set_bool("staff_pick_switch", true);
}
// if (get("staff_pick_switch").empty()) {
// set_bool("staff_pick_switch", false);
// }
if (get("sync_system_preset").empty()) {
set_bool("sync_system_preset", true);

View file

@ -1736,9 +1736,9 @@ void GUI_App::restart_networking()
if (app_config->get("sync_user_preset") == "true") {
start_sync_user_preset();
}
if (mainframe && this->app_config->get("staff_pick_switch") == "true") {
if (mainframe->m_webview) { mainframe->m_webview->SendDesignStaffpick(has_model_mall()); }
}
// if (mainframe && this->app_config->get("staff_pick_switch") == "true") {
// if (mainframe->m_webview) { mainframe->m_webview->SendDesignStaffpick(has_model_mall()); }
// }
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(" exit, m_agent=%1%")%m_agent;
}
@ -2989,10 +2989,10 @@ void GUI_App::update_label_colours_from_appconfig()
void GUI_App::update_publish_status()
{
mainframe->show_publish_button(has_model_mall());
if (app_config->get("staff_pick_switch") == "true") {
mainframe->m_webview->SendDesignStaffpick(has_model_mall());
}
// mainframe->show_publish_button(has_model_mall());
// if (app_config->get("staff_pick_switch") == "true") {
// mainframe->m_webview->SendDesignStaffpick(has_model_mall());
// }
}
bool GUI_App::has_model_mall()
@ -3818,22 +3818,22 @@ std::string GUI_App::handle_web_request(std::string cmd)
}
}
}
else if (command_str.compare("modelmall_model_advise_get") == 0) {
if (mainframe && this->app_config->get("staff_pick_switch") == "true") {
if (mainframe->m_webview) {
mainframe->m_webview->SendDesignStaffpick(has_model_mall());
}
}
}
else if (command_str.compare("modelmall_model_open") == 0) {
if (root.get_child_optional("data") != boost::none) {
pt::ptree data_node = root.get_child("data");
boost::optional<std::string> id = data_node.get_optional<std::string>("id");
if (id.has_value() && mainframe->m_webview) {
mainframe->m_webview->OpenModelDetail(id.value(), m_agent);
}
}
}
// else if (command_str.compare("modelmall_model_advise_get") == 0) {
// if (mainframe && this->app_config->get("staff_pick_switch") == "true") {
// if (mainframe->m_webview) {
// mainframe->m_webview->SendDesignStaffpick(has_model_mall());
// }
// }
// }
// else if (command_str.compare("modelmall_model_open") == 0) {
// if (root.get_child_optional("data") != boost::none) {
// pt::ptree data_node = root.get_child("data");
// boost::optional<std::string> id = data_node.get_optional<std::string>("id");
// if (id.has_value() && mainframe->m_webview) {
// mainframe->m_webview->OpenModelDetail(id.value(), m_agent);
// }
// }
// }
else if (command_str.compare("homepage_open_recentfile") == 0) {
if (root.get_child_optional("data") != boost::none) {
pt::ptree data_node = root.get_child("data");

View file

@ -630,10 +630,10 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
app_config->set_bool(param, checkbox->GetValue());
app_config->save();
if (param == "staff_pick_switch") {
bool pbool = app_config->get("staff_pick_switch") == "true";
wxGetApp().switch_staff_pick(pbool);
}
// if (param == "staff_pick_switch") {
// bool pbool = app_config->get("staff_pick_switch") == "true";
// wxGetApp().switch_staff_pick(pbool);
// }
// backup
if (param == "backup_switch") {
@ -1008,9 +1008,9 @@ wxWindow* PreferencesDialog::create_general_page()
_L("If enabled, sets OrcaSlicer as default application to open .step files"), 50, "associate_step");
#endif // _WIN32
auto title_modelmall = create_item_title(_L("Online Models"), page, _L("Online Models"));
// auto title_modelmall = create_item_title(_L("Online Models"), page, _L("Online Models"));
// auto item_backup = create_item_switch(_L("Backup switch"), page, _L("Backup switch"), "units");
auto item_modelmall = create_item_checkbox(_L("Show online staff-picked models on the home page"), page, _L("Show online staff-picked models on the home page"), 50, "staff_pick_switch");
// auto item_modelmall = create_item_checkbox(_L("Show online staff-picked models on the home page"), page, _L("Show online staff-picked models on the home page"), 50, "staff_pick_switch");
auto title_project = create_item_title(_L("Project"), page, "");
auto item_max_recent_count = create_item_input(_L("Maximum recent projects"), "", page, _L("Maximum count of recent projects"), "max_recent_count", [](wxString value) {
@ -1060,18 +1060,18 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(item_associate_stl, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_associate_step, 0, wxTOP, FromDIP(3));
#endif // _WIN32
auto item_title_modelmall = sizer_page->Add(title_modelmall, 0, wxTOP | wxEXPAND, FromDIP(20));
auto item_item_modelmall = sizer_page->Add(item_modelmall, 0, wxTOP, FromDIP(3));
auto update_modelmall = [this, item_title_modelmall, item_item_modelmall] (wxEvent & e) {
bool has_model_mall = wxGetApp().has_model_mall();
item_title_modelmall->Show(has_model_mall);
item_item_modelmall->Show(has_model_mall);
Layout();
Fit();
};
wxCommandEvent eee(wxEVT_COMBOBOX);
update_modelmall(eee);
item_region->GetItem(size_t(2))->GetWindow()->Bind(wxEVT_COMBOBOX, update_modelmall);
// auto item_title_modelmall = sizer_page->Add(title_modelmall, 0, wxTOP | wxEXPAND, FromDIP(20));
// auto item_item_modelmall = sizer_page->Add(item_modelmall, 0, wxTOP, FromDIP(3));
// auto update_modelmall = [this, item_title_modelmall, item_item_modelmall] (wxEvent & e) {
// bool has_model_mall = wxGetApp().has_model_mall();
// item_title_modelmall->Show(has_model_mall);
// item_item_modelmall->Show(has_model_mall);
// Layout();
// Fit();
// };
// wxCommandEvent eee(wxEVT_COMBOBOX);
// update_modelmall(eee);
// item_region->GetItem(size_t(2))->GetWindow()->Bind(wxEVT_COMBOBOX, update_modelmall);
sizer_page->Add(title_project, 0, wxTOP| wxEXPAND, FromDIP(20));
sizer_page->Add(item_max_recent_count, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_save_choise, 0, wxTOP, FromDIP(3));

View file

@ -430,23 +430,23 @@ void WebViewPanel::SendRecentList(int images)
void WebViewPanel::SendDesignStaffpick(bool on)
{
if (on) {
get_design_staffpick(0, 60, [this](std::string body) {
if (body.empty() || body.front() != '{') {
BOOST_LOG_TRIVIAL(warning) << "get_design_staffpick failed " + body;
return;
}
CallAfter([this, body] {
auto body2 = from_u8(body);
body2.insert(1, "\"command\": \"modelmall_model_advise_get\", ");
RunScript(wxString::Format("window.postMessage(%s)", body2));
});
});
} else {
std::string body2 = "{\"total\":0, \"hits\":[]}";
body2.insert(1, "\"command\": \"modelmall_model_advise_get\", ");
RunScript(wxString::Format("window.postMessage(%s)", body2));
}
// if (on) {
// get_design_staffpick(0, 60, [this](std::string body) {
// if (body.empty() || body.front() != '{') {
// BOOST_LOG_TRIVIAL(warning) << "get_design_staffpick failed " + body;
// return;
// }
// CallAfter([this, body] {
// auto body2 = from_u8(body);
// body2.insert(1, "\"command\": \"modelmall_model_advise_get\", ");
// RunScript(wxString::Format("window.postMessage(%s)", body2));
// });
// });
// } else {
// std::string body2 = "{\"total\":0, \"hits\":[]}";
// body2.insert(1, "\"command\": \"modelmall_model_advise_get\", ");
// RunScript(wxString::Format("window.postMessage(%s)", body2));
// }
}
void WebViewPanel::OpenModelDetail(std::string id, NetworkAgent *agent)
@ -488,17 +488,17 @@ void WebViewPanel::ShowNetpluginTip()
void WebViewPanel::get_design_staffpick(int offset, int limit, std::function<void(std::string)> callback)
{
auto host = wxGetApp().get_http_url(wxGetApp().app_config->get_country_code(), "v1/design-service/design/staffpick");
std::string url = (boost::format("%1%/?offset=%2%&limit=%3%") % host % offset % limit).str();
// auto host = wxGetApp().get_http_url(wxGetApp().app_config->get_country_code(), "v1/design-service/design/staffpick");
// std::string url = (boost::format("%1%/?offset=%2%&limit=%3%") % host % offset % limit).str();
Http http = Http::get(url);
http.header("accept", "application/json")
.header("Content-Type", "application/json")
.on_complete([this, callback](std::string body, unsigned status) { callback(body); })
.on_error([this, callback](std::string body, std::string error, unsigned status) {
callback(body);
})
.perform();
// Http http = Http::get(url);
// http.header("accept", "application/json")
// .header("Content-Type", "application/json")
// .on_complete([this, callback](std::string body, unsigned status) { callback(body); })
// .on_error([this, callback](std::string body, std::string error, unsigned status) {
// callback(body);
// })
// .perform();
}
int WebViewPanel::get_model_mall_detail_url(std::string *url, std::string id)