fix: add resolution for undefined conflicts

This commit is contained in:
Ian Chua
2026-06-09 18:12:32 +08:00
parent dedd878af1
commit 6bd30977c5
3 changed files with 19 additions and 16 deletions

View File

@@ -4965,13 +4965,17 @@ void GUI_App::on_http_error(wxCommandEvent &evt)
break; break;
case -3: case -3:
text = _u8L("Cloud sync conflict: a preset with the same name was previously deleted from the cloud.\n" text = _u8L("Cloud sync conflict: a preset with the same name was previously deleted from the cloud.\n"
"Do you want to push this new copy to the cloud?"); "Delete will delete your local preset. Force push overwrites it with your local preset.");
break;
default:
text = _u8L("Cloud sync conflict: there was an unexpected or unidentified preset conflict.\n"
"Pull downloads the cloud copy. Force push overwrites it with your local preset.");
break; break;
}; };
plater->get_notification_manager()->push_orca_sync_conflict_notification( plater->get_notification_manager()->push_orca_sync_conflict_notification(
text, text, conflict_code,
conflict_code == -3 ? nullptr : std::function<bool(wxEvtHandler*)>{[this](wxEvtHandler*) { [this](wxEvtHandler*) {
// Runs on the GUI thread (on_http_error is a queued wx event); restart_sync_user_preset() // Runs on the GUI thread (on_http_error is a queued wx event); restart_sync_user_preset()
// already joins the old sync thread off the UI thread, so no extra thread is needed here. // already joins the old sync thread off the UI thread, so no extra thread is needed here.
if (is_closing() || !m_agent || !preset_bundle) if (is_closing() || !m_agent || !preset_bundle)
@@ -4979,7 +4983,7 @@ void GUI_App::on_http_error(wxCommandEvent &evt)
BOOST_LOG_TRIVIAL(info) << "Pulling Orca Cloud settings to resolve sync conflict."; BOOST_LOG_TRIVIAL(info) << "Pulling Orca Cloud settings to resolve sync conflict.";
restart_sync_user_preset(); restart_sync_user_preset();
return true; return true;
}}, },
[this, conflict_setting_id](wxEvtHandler*) { [this, conflict_setting_id](wxEvtHandler*) {
if (mainframe == nullptr) if (mainframe == nullptr)
return false; return false;

View File

@@ -2416,18 +2416,12 @@ void NotificationManager::OrcaSyncConflictNotification::render_text(ImGuiWrapper
} }
const float action_y = starting_y + m_endlines.size() * shift_y; const float action_y = starting_y + m_endlines.size() * shift_y;
std::string pull_text = ""; const std::string pull_text = conflict_code == -3 ? _u8L("Delete") : _u8L("Pull");
float padding = 0.f; render_hyperlink_action(imgui, x_offset, action_y, pull_text, "##orca_sync_pull",
[this] { if (m_pull_callback && m_pull_callback(m_evt_handler)) close(); });
if (m_pull_callback) {
pull_text = _u8L("Pull");
padding = ImGui::CalcTextSize((pull_text + " ").c_str()).x;
render_hyperlink_action(imgui, x_offset, action_y, pull_text, "##orca_sync_pull",
[this] { if (m_pull_callback && m_pull_callback(m_evt_handler)) close(); });
}
if (m_force_push_callback) { if (m_force_push_callback) {
const std::string force_push_text = _u8L("Force push"); const std::string force_push_text = _u8L("Force push");
const float force_x = x_offset + padding; const float force_x = x_offset + ImGui::CalcTextSize((pull_text + " ").c_str()).x;
render_hyperlink_action(imgui, force_x, action_y, force_push_text, "##orca_sync_force_push", render_hyperlink_action(imgui, force_x, action_y, force_push_text, "##orca_sync_force_push",
[this] { if (m_force_push_callback && m_force_push_callback(m_evt_handler)) close(); }); [this] { if (m_force_push_callback && m_force_push_callback(m_evt_handler)) close(); });
} }
@@ -2443,13 +2437,14 @@ void NotificationManager::push_shared_profiles_notification(const std::string& e
} }
void NotificationManager::push_orca_sync_conflict_notification(const std::string& text, void NotificationManager::push_orca_sync_conflict_notification(const std::string& text,
int conflict_code,
std::function<bool(wxEvtHandler*)> pull_callback, std::function<bool(wxEvtHandler*)> pull_callback,
std::function<bool(wxEvtHandler*)> force_push_callback) std::function<bool(wxEvtHandler*)> force_push_callback)
{ {
close_notification_of_type(NotificationType::OrcaSyncConflict); close_notification_of_type(NotificationType::OrcaSyncConflict);
NotificationData data{ NotificationType::OrcaSyncConflict, NotificationLevel::WarningNotificationLevel, 0, text }; NotificationData data{ NotificationType::OrcaSyncConflict, NotificationLevel::WarningNotificationLevel, 0, text };
push_notification_data(std::make_unique<NotificationManager::OrcaSyncConflictNotification>( push_notification_data(std::make_unique<NotificationManager::OrcaSyncConflictNotification>(
data, m_id_provider, m_evt_handler, std::move(pull_callback), std::move(force_push_callback)), 0); data, m_id_provider, m_evt_handler, std::move(pull_callback), std::move(force_push_callback), conflict_code), 0);
} }
void NotificationManager::push_download_URL_progress_notification(size_t id, const std::string& text, std::function<bool(DownloaderUserAction, int)> user_action_callback) void NotificationManager::push_download_URL_progress_notification(size_t id, const std::string& text, std::function<bool(DownloaderUserAction, int)> user_action_callback)

View File

@@ -279,6 +279,7 @@ public:
// Shared profiles available for selected printer // Shared profiles available for selected printer
void push_shared_profiles_notification(const std::string& explore_url); void push_shared_profiles_notification(const std::string& explore_url);
void push_orca_sync_conflict_notification(const std::string& text, void push_orca_sync_conflict_notification(const std::string& text,
int conflict_code,
std::function<bool(wxEvtHandler*)> pull_callback, std::function<bool(wxEvtHandler*)> pull_callback,
std::function<bool(wxEvtHandler*)> force_push_callback); std::function<bool(wxEvtHandler*)> force_push_callback);
@@ -905,10 +906,12 @@ private:
public: public:
OrcaSyncConflictNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler, OrcaSyncConflictNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler,
std::function<bool(wxEvtHandler*)> pull_callback, std::function<bool(wxEvtHandler*)> pull_callback,
std::function<bool(wxEvtHandler*)> force_push_callback) std::function<bool(wxEvtHandler*)> force_push_callback,
int conflict_code)
: PopNotification(n, id_provider, evt_handler) : PopNotification(n, id_provider, evt_handler)
, m_pull_callback(std::move(pull_callback)) , m_pull_callback(std::move(pull_callback))
, m_force_push_callback(std::move(force_push_callback)) , m_force_push_callback(std::move(force_push_callback))
, conflict_code(conflict_code)
{ {
m_multiline = true; m_multiline = true;
} }
@@ -920,6 +923,7 @@ private:
std::function<bool(wxEvtHandler*)> m_pull_callback; std::function<bool(wxEvtHandler*)> m_pull_callback;
std::function<bool(wxEvtHandler*)> m_force_push_callback; std::function<bool(wxEvtHandler*)> m_force_push_callback;
int conflict_code;
}; };
class SlicingProgressNotification; class SlicingProgressNotification;