FIX: [STUDIO-2865] only send changed thubmails to home page

Change-Id: I88ae0dd3a47c4cf02bf97978a22fd72ed0ef0299
This commit is contained in:
chunmao.guo 2023-05-18 18:42:50 +08:00 committed by Lane.Wei
parent 1cde1ebaed
commit dfd049374c
6 changed files with 18 additions and 14 deletions

View file

@ -21,6 +21,7 @@ var RightBtnFilePath='';
var MousePosX=0;
var MousePosY=0;
var sImages = {};
function Set_RecentFile_MouseRightBtn_Event()
{
@ -183,10 +184,11 @@ function ShowRecentFileList( pList )
{
let OneFile=pList[n];
let sImg=OneFile["image"];
let sPath=OneFile['path'];
let sImg=OneFile["image"] || sImages[sPath];
let sTime=OneFile['time'];
let sName=OneFile['project_name'];
sImages[sPath] = sImg;
//let index=sPath.lastIndexOf('\\')>0?sPath.lastIndexOf('\\'):sPath.lastIndexOf('\/');
//let sShortName=sPath.substring(index+1,sPath.length);

View file

@ -3751,7 +3751,7 @@ std::string GUI_App::handle_web_request(std::string cmd)
else if (command_str.compare("get_recent_projects") == 0) {
if (mainframe) {
if (mainframe->m_webview) {
mainframe->m_webview->SendRecentList(from_u8(sequence_id.value()));
mainframe->m_webview->SendRecentList(INT_MAX);
}
}
}

View file

@ -2615,7 +2615,7 @@ void MainFrame::set_max_recent_count(int max)
}
wxGetApp().app_config->set_recent_projects(recent_projects);
wxGetApp().app_config->save();
m_webview->SendRecentList("");
m_webview->SendRecentList(-1);
}
}
@ -3082,7 +3082,7 @@ void MainFrame::add_to_recent_projects(const wxString& filename)
}
wxGetApp().app_config->set_recent_projects(recent_projects);
wxGetApp().app_config->save();
m_webview->SendRecentList("");
m_webview->SendRecentList(0);
}
}
@ -3136,7 +3136,7 @@ inline void MainFrame::FileHistory::SetMaxFiles(int max)
RemoveFileFromHistory(--numFiles);
}
void MainFrame::get_recent_projects(boost::property_tree::wptree &tree)
void MainFrame::get_recent_projects(boost::property_tree::wptree &tree, int images)
{
for (size_t i = 0; i < m_recent_projects.GetCount(); ++i) {
boost::property_tree::wptree item;
@ -3148,8 +3148,10 @@ void MainFrame::get_recent_projects(boost::property_tree::wptree &tree)
if (!ec) {
std::wstring time = wxDateTime(t).FormatISOCombined(' ').ToStdWstring();
item.put(L"time", time);
auto thumbnail = m_recent_projects.GetThumbnailUrl(i);
if (!thumbnail.empty()) item.put(L"image", thumbnail);
if (i <= images) {
auto thumbnail = m_recent_projects.GetThumbnailUrl(i);
if (!thumbnail.empty()) item.put(L"image", thumbnail);
}
} else {
item.put(L"time", _L("File is missing"));
}
@ -3182,7 +3184,7 @@ void MainFrame::open_recent_project(size_t file_id, wxString const & filename)
}
wxGetApp().app_config->set_recent_projects(recent_projects);
wxGetApp().app_config->save();
m_webview->SendRecentList("");
m_webview->SendRecentList(-1);
}
}
}
@ -3206,7 +3208,7 @@ void MainFrame::remove_recent_project(size_t file_id, wxString const &filename)
}
wxGetApp().app_config->set_recent_projects(recent_projects);
wxGetApp().app_config->save();
m_webview->SendRecentList("");
m_webview->SendRecentList(-1);
}
void MainFrame::load_url(wxString url)

View file

@ -318,7 +318,7 @@ public:
bool save_project_as(const wxString& filename = wxString());
void add_to_recent_projects(const wxString& filename);
void get_recent_projects(boost::property_tree::wptree & tree);
void get_recent_projects(boost::property_tree::wptree &tree, int images);
void open_recent_project(size_t file_id, wxString const & filename);
void remove_recent_project(size_t file_id, wxString const &filename);

View file

@ -414,12 +414,12 @@ void WebViewPanel::OnFreshLoginStatus(wxTimerEvent &event)
Slic3r::GUI::wxGetApp().get_login_info();
}
void WebViewPanel::SendRecentList(wxString const &sequence_id)
void WebViewPanel::SendRecentList(int images)
{
boost::property_tree::wptree req;
boost::property_tree::wptree data;
wxGetApp().mainframe->get_recent_projects(data);
req.put(L"sequence_id", sequence_id);
wxGetApp().mainframe->get_recent_projects(data, images);
req.put(L"sequence_id", "");
req.put(L"command", L"get_recent_projects");
req.put_child(L"response", data);
std::wostringstream oss;

View file

@ -93,7 +93,7 @@ public:
void OnFreshLoginStatus(wxTimerEvent &event);
public:
void SendRecentList(wxString const &sequence_id);
void SendRecentList(int images);
void SendDesignStaffpick(NetworkAgent *agent);
void SendLoginInfo();
void ShowNetpluginTip();