Skip to content

Commit

Permalink
Hide all panes on selection change before showing relevant panes
Browse files Browse the repository at this point in the history
Consider two workflows, one provides `def` keyword for
dictionary lookup and another that provides `gdef` keyword
for searching Google for definition.

Consider the sequence of user actions and pane behavior:
1. User types "def blah"
2. We show the dictionary pane
3. User changes the typed query to "gdef blah"
4. We show the google search pane

Note that at 4, we now have two panes visible as pane from
2 was never hidden.

With this change, we add another step between 2 and 3 for
hiding the dictionary pane.
  • Loading branch information
mr-pennyworth committed Aug 19, 2024
1 parent a43a9b7 commit f2b8aee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions AlfredExtraPane.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 0.2.9;
MARKETING_VERSION = 0.2.10;
ONLY_ACTIVE_ARCH = NO;
OTHER_CODE_SIGN_FLAGS = "--deep";
PRODUCT_BUNDLE_IDENTIFIER = mr.pennyworth.AlfredExtraPane;
Expand All @@ -438,7 +438,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 0.2.9;
MARKETING_VERSION = 0.2.10;
ONLY_ACTIVE_ARCH = NO;
OTHER_CODE_SIGN_FLAGS = "--deep";
PRODUCT_BUNDLE_IDENTIFIER = mr.pennyworth.AlfredExtraPane;
Expand Down
10 changes: 10 additions & 0 deletions AlfredExtraPane/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
dump(confs)
panes = confs.map { Pane(workflowPaneConfig: $0) }
Alfred.onItemSelect { item in
// Every time the selection changes, the newly selected item
// could be from the same workflow as the previously selected item,
// or from a different workflow. In the latter case, we need to hide
// panes specific to the previously selected item's workflow.
//
// Instead of that, we hide all panes, and then render the panes
// that match the newly selected item's workflow. If this causes too
// much flicker, we can optimize this later.
self.panes.forEach({ $0.hide() })

// First, render panes that have exact match with workflowUID.
// Then, if no exact match is found, render the wildcard panes.
[
Expand Down

0 comments on commit f2b8aee

Please sign in to comment.