fix(refresh): resync after toolbar and branch actions
Some checks failed
Build Releases / Build Linux x64 DEB (push) Failing after 1m32s
Build Releases / Build Windows x64 (push) Successful in 7m2s
Build Releases / Create Release (push) Has been skipped

This commit is contained in:
2026-06-19 00:09:21 -05:00
parent 279fe6e7f9
commit e74e6ec513

View File

@@ -231,6 +231,11 @@ bool run_repository_action(const std::vector<std::string>& arguments, const std:
return true;
}
void mark_action_refresh(RepositoryView& repository) {
mark_repository_refreshed(repository);
repository.pending_background_refresh = true;
}
void draw_dotted_bezier(ImDrawList* draw, const ImVec2& start, const ImVec2& control_start,
const ImVec2& control_end, const ImVec2& end, ImU32 color, float radius, float spacing) {
const float estimated_length = std::hypot(end.x - start.x, end.y - start.y) +
@@ -839,12 +844,14 @@ void branch_context(const std::string& branch, bool remote) {
clear_sidebar_filter();
}
if (!remote && ImGui::MenuItem(ICON_TB_UPLOAD " Push branch")) {
g_git_manager->pushBranch(repo(), branch, g_notice);
if (g_git_manager->pushBranch(repo(), branch, g_notice))
mark_action_refresh(repo());
clear_sidebar_filter();
}
if (remote && ImGui::MenuItem(ICON_TB_DOWNLOAD " Fetch")) {
const size_t slash = branch.find('/');
g_git_manager->fetch(repo(), slash == std::string::npos ? branch : branch.substr(0, slash), g_notice);
if (g_git_manager->fetch(repo(), slash == std::string::npos ? branch : branch.substr(0, slash), g_notice))
mark_action_refresh(repo());
}
ImGui::Separator();
if (ImGui::MenuItem(ICON_TB_COPY " Copy branch name")) copy_to_clipboard(branch, "branch name");
@@ -3428,11 +3435,15 @@ void draw_app() {
begin_inline_branch(repo().selected_commit >= 0 ? repo().selected_commit : 0);
}
ImGui::SameLine(0, action_spacing);
if (toolbar_action("stash", "Stash", ICON_TB_BOX_ARCHIVE, "Stash changes", true, false, 58))
g_git_manager->stash(repo(), g_notice);
if (toolbar_action("stash", "Stash", ICON_TB_BOX_ARCHIVE, "Stash changes", true, false, 58)) {
if (g_git_manager->stash(repo(), g_notice))
mark_action_refresh(repo());
}
ImGui::SameLine(0, action_spacing);
if (toolbar_action("pop", "Pop", ICON_TB_BOX_OPEN, "Pop latest stash", true, false, 54))
g_git_manager->popStash(repo(), g_notice);
if (toolbar_action("pop", "Pop", ICON_TB_BOX_OPEN, "Pop latest stash", true, false, 54)) {
if (g_git_manager->popStash(repo(), g_notice))
mark_action_refresh(repo());
}
draw_open_in_button();
ImGui::EndChild();
ImGui::PopStyleColor();
@@ -3493,15 +3504,19 @@ void draw_app() {
draw_popups();
ImGui::End();
if (toolbar_action_to_execute == ToolbarActionRequest::pull)
g_git_manager->pull(repo(), g_user_data->pullMode(), g_notice);
else if (toolbar_action_to_execute == ToolbarActionRequest::push)
g_git_manager->push(repo(), g_notice);
if (toolbar_action_to_execute == ToolbarActionRequest::pull) {
if (g_git_manager->pull(repo(), g_user_data->pullMode(), g_notice))
mark_action_refresh(repo());
} else if (toolbar_action_to_execute == ToolbarActionRequest::push) {
if (g_git_manager->push(repo(), g_notice))
mark_action_refresh(repo());
}
if (toolbar_action_to_execute != ToolbarActionRequest::none)
g_running_toolbar_action = ToolbarActionRequest::none;
if (!branch_checkout_to_execute.empty()) {
g_git_manager->checkoutBranch(repo(), branch_checkout_to_execute, g_notice);
if (g_git_manager->checkoutBranch(repo(), branch_checkout_to_execute, g_notice))
mark_action_refresh(repo());
g_running_branch_checkout.clear();
}
}