Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] - Default to web search when local-search has zero results #129

Closed
audibleblink opened this issue Oct 28, 2021 · 0 comments · Fixed by #145
Closed

[Feature Request] - Default to web search when local-search has zero results #129

audibleblink opened this issue Oct 28, 2021 · 0 comments · Fixed by #145
Labels
🔨 Feature New feature or request

Comments

@audibleblink
Copy link

Muscle memory has me cmd+T-ing then immediately typing a url or search term, since browsers default to focusing the url bar. When setting an actual Homepage though, focus is on the page and not the URL bar anymore.

What do you think about mixing best of both worlds: Flame local-search primarily does just that, searches your apps and bookmarks, but when there are zero matches, it can use a default search engine?

I've never written TypeScript or React, but I've mocked something up that works on my fork.
It would need to be made configurable, and probably require some changes to the Settings page.
It's ugly, but it's working pretty good for me so far.

diff --git a/client/src/components/SearchBar/SearchBar.tsx b/client/src/components/SearchBar/SearchBar.tsx
index 7a91525..e150bc3 100644
--- a/client/src/components/SearchBar/SearchBar.tsx
+++ b/client/src/components/SearchBar/SearchBar.tsx
@@ -91,8 +91,11 @@ const SearchBar = (props: ComponentProps): JSX.Element => {
         // Local query -> redirect if at least 1 result found
         if (appSearchResult?.length) {
           redirectUrl(appSearchResult[0].url, sameTab);
-        } else if (bookmarkSearchResult?.length) {
+        } else if (bookmarkSearchResult?.[0]?.bookmarks?.length) {
           redirectUrl(bookmarkSearchResult[0].bookmarks[0].url, sameTab);
+        } else {
+          const url = `https://google.com/search?q=${search}`;
+          redirectUrl(url, sameTab);
         }
       } else {
         // Valid query -> redirect to search results
@pawelmalak pawelmalak added the 🔨 Feature New feature or request label Nov 8, 2021
@pawelmalak pawelmalak linked a pull request Nov 8, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 Feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants