Skip to content

Commit 076fe32

Browse files
committed
Add support for duckduckgo and bing search engines
1 parent 731e0d0 commit 076fe32

File tree

7 files changed

+71
-18
lines changed

7 files changed

+71
-18
lines changed

bun.lockb

402 Bytes
Binary file not shown.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@types/jest": "^29.2.1",
6060
"@types/lodash": "^4.14.182",
6161
"@types/luxon": "^2.0.9",
62+
"@types/react": "^19.0.2",
6263
"@types/react-native": "^0.66.12",
6364
"@types/react-test-renderer": "^18.0.0",
6465
"@types/uuid": "^9.0.0",

src/stores/keystroke.store.ts

+32-8
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,38 @@ export const createKeystrokeStore = (root: IRootStore) => {
253253

254254
// If there are no items, or if the query is a meta (⌘ is pressed) query, open a google search
255255
if (!root.ui.items.length || meta) {
256-
Linking.openURL(
257-
`https://google.com/search?q=${encodeURI(root.ui.query)}`,
258-
).catch(e => {
259-
solNative.showToast(
260-
`Could not open URL: ${root.ui.query}, error: ${e}`,
261-
'error',
262-
)
263-
})
256+
switch (root.ui.searchEngine) {
257+
case 'google':
258+
Linking.openURL(
259+
`https://google.com/search?q=${encodeURI(root.ui.query)}`,
260+
).catch(e => {
261+
solNative.showToast(
262+
`Could not open URL: ${root.ui.query}, error: ${e}`,
263+
'error',
264+
)
265+
})
266+
break
267+
case 'duckduckgo':
268+
Linking.openURL(
269+
`https://duckduckgo.com/?q=${encodeURI(root.ui.query)}`,
270+
).catch(e => {
271+
solNative.showToast(
272+
`Could not open URL: ${root.ui.query}, error: ${e}`,
273+
'error',
274+
)
275+
})
276+
break
277+
case 'bing':
278+
Linking.openURL(
279+
`https://bing.com/search?q=${encodeURI(root.ui.query)}`,
280+
).catch(e => {
281+
solNative.showToast(
282+
`Could not open URL: ${root.ui.query}, error: ${e}`,
283+
'error',
284+
)
285+
})
286+
break
287+
}
264288

265289
solNative.hideWindow()
266290
return

src/stores/ui.store.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ let minisearch = new MiniSearch({
113113
})
114114

115115
export type UIStore = ReturnType<typeof createUIStore>
116+
type SearchEngine = 'google' | 'bing' | 'duckduckgo'
116117

117118
export const createUIStore = (root: IRootStore) => {
118119
let persist = async () => {
@@ -184,6 +185,7 @@ export const createUIStore = (root: IRootStore) => {
184185
`/Users/${solNative.userName()}/Music`,
185186
]
186187
store.emojiPickerDisabled = parsedStore.emojiPickerDisabled ?? false
188+
store.searchEngine = parsedStore.searchEngine ?? 'google'
187189
})
188190

189191
solNative.setLaunchAtLogin(parsedStore.launchAtLogin ?? true)
@@ -220,6 +222,7 @@ export const createUIStore = (root: IRootStore) => {
220222
isAccessibilityTrusted: false,
221223
calendarAuthorizationStatus: null as CalendarAuthorizationStatus | null,
222224
onboardingStep: 'v1_start' as OnboardingStep,
225+
searchEngine: 'google' as SearchEngine,
223226
globalShortcut: 'option' as 'command' | 'option' | 'control',
224227
scratchpadShortcut: 'command' as 'command' | 'option' | 'none',
225228
clipboardManagerShortcut: 'shift' as 'shift' | 'option' | 'none',
@@ -806,6 +809,10 @@ export const createUIStore = (root: IRootStore) => {
806809
store.emojiPickerDisabled = !store.emojiPickerDisabled
807810
solNative.setEmojiPickerDisabled(store.emojiPickerDisabled)
808811
},
812+
813+
setSearchEngine: (engine: SearchEngine) => {
814+
store.searchEngine = engine
815+
},
809816
})
810817

811818
// solNative.setWindowHeight(50)

src/widgets/search.widget.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,7 @@ export const SearchWidget: FC<Props> = observer(() => {
148148
'flex-1': !!store.ui.query,
149149
})}>
150150
<View className="flex-row items-center gap-2 px-3">
151-
{!items.length && (
152-
<View className="h-6 w-6 items-center justify-center">
153-
<Image source={Assets.googleLogo} className="h-4 w-4" />
154-
</View>
155-
)}
156-
<MainInput className="flex-1" hideIcon={!items.length} />
151+
<MainInput className="flex-1" />
157152
</View>
158153

159154
{!!store.ui.query && (

src/widgets/settings.widget.tsx

+29-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ export const SettingsWidget: FC = observer(() => {
127127
{label: '⌘ ⇧ Space', value: 'command' as const},
128128
{label: '⇧ ⌥ Space', value: 'option' as const},
129129
{label: 'Disabled', value: 'none' as const},
130-
].map(({label, value}) => {
130+
].map(({label, value}, idx) => {
131131
return (
132132
<MyRadioButton
133+
index={idx}
133134
label={label}
134135
value={value}
135136
onValueChange={() => {
@@ -149,9 +150,10 @@ export const SettingsWidget: FC = observer(() => {
149150
{label: '⌘ ⇧ V', value: 'shift' as const},
150151
{label: '⌘ ⌥ V', value: 'option' as const},
151152
{label: 'Disabled', value: 'none' as const},
152-
].map(({label, value}) => {
153+
].map(({label, value}, idx) => {
153154
return (
154155
<MyRadioButton
156+
index={idx}
155157
label={label}
156158
value={value}
157159
onValueChange={() => {
@@ -163,6 +165,29 @@ export const SettingsWidget: FC = observer(() => {
163165
})}
164166
</View>
165167
</View>
168+
<View className="border-t border-lightBorder dark:border-darkBorder" />
169+
<View className="gap-3">
170+
<Text className="flex-1">Search Engine</Text>
171+
<View className="flex-1">
172+
{[
173+
{label: 'Google', value: 'google' as const},
174+
{label: 'DuckDuckGo', value: 'duckduckgo' as const},
175+
{label: 'Bing', value: 'bing' as const},
176+
].map(({label, value}, idx) => {
177+
return (
178+
<MyRadioButton
179+
index={idx}
180+
label={label}
181+
value={value}
182+
onValueChange={() => {
183+
store.ui.setSearchEngine(value)
184+
}}
185+
selected={store.ui.searchEngine === value}
186+
/>
187+
)
188+
})}
189+
</View>
190+
</View>
166191
</View>
167192

168193
<View className="p-3 subBg rounded gap-3">
@@ -214,9 +239,10 @@ export const SettingsWidget: FC = observer(() => {
214239
label: 'Screen with cursor',
215240
value: 'screenWithCursor' as const,
216241
},
217-
].map(({label, value}) => {
242+
].map(({label, value}, index) => {
218243
return (
219244
<MyRadioButton
245+
index={index}
220246
label={label}
221247
value={value}
222248
onValueChange={() => {

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"allowJs": true,
66
"strict": true,
77
"baseUrl": "./src",
8-
"jsx": "react-native",
8+
"jsx": "react-jsx",
99
"allowSyntheticDefaultImports": true,
1010
"esModuleInterop": true,
1111
"useDefineForClassFields": true,

0 commit comments

Comments
 (0)