Skip to content

Commit

Permalink
fix commit-tree updates on branch-filter usage
Browse files Browse the repository at this point in the history
  • Loading branch information
forgottosave committed Nov 13, 2024
1 parent 6997448 commit 9552da4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 3 additions & 7 deletions src/core/OSTreeTUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,9 @@ OSTreeTUI::OSTreeTUI(const std::string& repo, const std::vector<std::string> sta

// filter
filterManager =
std::unique_ptr<BranchBoxManager>(new BranchBoxManager(ostreeRepo, visibleBranches));
std::unique_ptr<BranchBoxManager>(new BranchBoxManager(*this, ostreeRepo, visibleBranches));
filterView =
Renderer(filterManager->branchBoxes, [&] { return filterManager->branchBoxRender(); });
filterView = CatchEvent(filterView, [&](Event event) {
if (event.is_mouse() && event.mouse().button == Mouse::Button::Left) {
refresh_commitListComoponent();
}
return false;
});

// interchangeable view (composed)
manager = std::unique_ptr<Manager>(new Manager(*this, infoView, filterView));
Expand Down Expand Up @@ -201,6 +195,8 @@ void OSTreeTUI::refresh_commitComponents() {
void OSTreeTUI::refresh_commitListComoponent() {
using namespace ftxui;

visibleCommitViewMap = parseVisibleCommitMap(ostreeRepo, visibleBranches);

commitListComponent->DetachAllChildren();
refresh_commitComponents();
Component tmp = Container::Horizontal({tree, commitList});
Expand Down
10 changes: 8 additions & 2 deletions src/core/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,19 @@ const int& Manager::getTabIndex() const {

// BranchBoxManager

BranchBoxManager::BranchBoxManager(cpplibostree::OSTreeRepo& repo,
BranchBoxManager::BranchBoxManager(OSTreeTUI& ostreetui, cpplibostree::OSTreeRepo& repo,
std::unordered_map<std::string, bool>& visibleBranches) {
using namespace ftxui;

CheckboxOption cboption = {
.on_change = [&] {
ostreetui.refresh_commitListComoponent();
}
};

// branch visibility
for (const auto& branch : repo.getBranches()) {
branchBoxes->Add(Checkbox(branch, &(visibleBranches.at(branch))));
branchBoxes->Add(Checkbox(branch, &(visibleBranches.at(branch)), cboption));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class BranchBoxManager {
ftxui::Component branchBoxes = ftxui::Container::Vertical({});

public:
BranchBoxManager(cpplibostree::OSTreeRepo& repo,
BranchBoxManager(OSTreeTUI& ostreetui, cpplibostree::OSTreeRepo& repo,
std::unordered_map<std::string, bool>& visibleBranches);

/**
Expand Down

0 comments on commit 9552da4

Please sign in to comment.