Skip to content

Commit

Permalink
Refactor bt.cpp & update build to 4.0.2
Browse files Browse the repository at this point in the history
- Updated the build version in `build.yml` from `4.0.1` to `4.0.2`.
- In `bt.cpp`, refactored the picker logic to use a structured decision-making process. This includes handling conditions like `force_picker`, `picker_always`, `picker_on_conflict`, and `picker_on_no_rule`. Added `pick_reason` to improve logging and decision transparency.
- Updated the subproject commit in `common` to include changes up to a new commit marked as `-dirty`.
- Added release notes for version `4.0.2` in `release-notes.md`, highlighting the bug fix for picker visibility issues, credited to @Mythrix for their contribution in resolving issue `#40`.
  • Loading branch information
aloneguid committed Jul 18, 2024
1 parent bd7d5b7 commit 4c83c89
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'Build'

env:
VERSION: 4.0.1
VERSION: 4.0.2
BUILD_TYPE: Release
ARCH: x64
VCPKG_CONFIG: Release
Expand Down
30 changes: 24 additions & 6 deletions bt/bt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,37 @@ void track_event(string name) {

void open(bt::url_payload up, bool force_picker = false) {

bool picker_hotkeyed =
g_config.picker_always ||
bt::ui::picker_app::is_hotkey_down();

g_pipeline.process(up);

if(force_picker || picker_hotkeyed) {
// decision whether to show picker or not
bool show_picker{force_picker};
string pick_reason;
if(!show_picker) {
if(g_config.picker_always) {
show_picker = true;
pick_reason = "always";
} else if(bt::ui::picker_app::is_hotkey_down()) {
show_picker = true;
pick_reason = "hotkey";
} else if(g_config.picker_on_conflict || g_config.picker_on_no_rule) {
auto matches = bt::browser::match(g_config.browsers, up, g_config.default_profile_long_id);
if(g_config.picker_on_conflict && matches.size() > 1) {
show_picker = true;
pick_reason = "conflict";
} else if(g_config.picker_on_no_rule && matches[0].rule.is_fallback) {
show_picker = true;
pick_reason = "no rule";
}
}
}

if(show_picker) {
bt::ui::picker_app app{up.url};
auto bi = app.run();
if(bi) {
bt::url_opener::open(bi, up);
if(g_config.log_rule_hits) {
bt::rule_hit_log::i.write(up, bi, "");
bt::rule_hit_log::i.write(up, bi, "picker:" + pick_reason);
}
}
} else {
Expand Down
3 changes: 3 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 4.0.2
Fixed a bug where picker would not show up if it was configured to be shown on conflict or always. Thanks to @Mythrix in #40.

## 4.0.1

- Browsers installed via Windows Store (Firefox) are automatically detected and added to the list.
Expand Down

0 comments on commit 4c83c89

Please sign in to comment.