@@ -119,27 +119,32 @@ function ActualSearch() {
119
119
) ;
120
120
} ) ;
121
121
122
- const showSendButton = createMemo ( ( ) => {
122
+ type SearchState = "notsendable" | "sendable" | "sendableWithContact" ;
123
+
124
+ const searchState = createMemo < SearchState > ( ( ) => {
123
125
if ( debouncedSearchValue ( ) === "" ) {
124
- return false ;
125
- } else {
126
- const text = debouncedSearchValue ( ) . trim ( ) ;
127
- // Only want to check for something parseable if it's of reasonable length
128
- if ( text . length < 6 ) {
129
- return false ;
130
- }
131
- let success = false ;
132
- actions . handleIncomingString (
133
- text ,
134
- ( _error ) => {
135
- // noop
136
- } ,
137
- ( _result ) => {
138
- success = true ;
139
- }
140
- ) ;
141
- return success ;
126
+ return "notsendable" ;
127
+ }
128
+ const text = debouncedSearchValue ( ) . trim ( ) ;
129
+ // Only want to check for something parseable if it's of reasonable length
130
+ if ( text . length < 6 ) {
131
+ return "notsendable" ;
142
132
}
133
+ let state : SearchState = "notsendable" ;
134
+ actions . handleIncomingString (
135
+ text ,
136
+ ( _error ) => {
137
+ // noop
138
+ } ,
139
+ ( result ) => {
140
+ if ( result . lightning_address || result . lnurl ) {
141
+ state = "sendableWithContact" ;
142
+ } else {
143
+ state = "sendable" ;
144
+ }
145
+ }
146
+ ) ;
147
+ return state ;
143
148
} ) ;
144
149
145
150
function handleContinue ( ) {
@@ -278,43 +283,49 @@ function ActualSearch() {
278
283
</ button >
279
284
</ Show >
280
285
</ div >
281
- < Show when = { showSendButton ( ) } >
286
+ < Show when = { searchState ( ) !== "notsendable" } >
282
287
< Button intent = "green" onClick = { handleContinue } >
283
288
Continue
284
289
</ Button >
285
290
</ Show >
286
- < div class = "relative flex h-full max-h-[100svh] flex-col gap-3 overflow-y-scroll" >
287
- < Suspense >
288
- < div class = "sticky top-0 z-50 bg-m-grey-900/90 py-2 backdrop-blur-sm" >
289
- < h2 class = "text-xl font-semibold" > Contacts</ h2 >
290
- </ div >
291
- < Show when = { contacts . latest && contacts ?. latest . length > 0 } >
292
- < For each = { filteredContacts ( ) } >
293
- { ( contact ) => (
294
- < ContactButton
295
- contact = { contact }
296
- onClick = { ( ) => sendToContact ( contact ) }
297
- />
298
- ) }
299
- </ For >
300
- </ Show >
301
- </ Suspense >
302
- < ContactEditor createContact = { createContact } />
303
-
304
- < Suspense fallback = { < LoadingShimmer /> } >
305
- < Show when = { ! ! debouncedSearchValue ( ) } >
306
- < h2 class = "py-2 text-xl font-semibold" >
307
- Global Search
308
- </ h2 >
309
- < GlobalSearch
310
- searchValue = { debouncedSearchValue ( ) }
311
- sendToContact = { sendToContact }
312
- foundNpubs = { foundNpubs ( ) }
313
- />
314
- </ Show >
315
- </ Suspense >
316
- < div class = "h-4" />
317
- </ div >
291
+ < Show when = { searchState ( ) !== "sendable" } >
292
+ < div class = "relative flex h-full max-h-[100svh] flex-col gap-3 overflow-y-scroll" >
293
+ < Suspense >
294
+ < div class = "sticky top-0 z-50 bg-m-grey-900/90 py-2 backdrop-blur-sm" >
295
+ < h2 class = "text-xl font-semibold" > Contacts</ h2 >
296
+ </ div >
297
+ < Show
298
+ when = {
299
+ contacts . latest && contacts ?. latest . length > 0
300
+ }
301
+ >
302
+ < For each = { filteredContacts ( ) } >
303
+ { ( contact ) => (
304
+ < ContactButton
305
+ contact = { contact }
306
+ onClick = { ( ) => sendToContact ( contact ) }
307
+ />
308
+ ) }
309
+ </ For >
310
+ </ Show >
311
+ </ Suspense >
312
+ < ContactEditor createContact = { createContact } />
313
+
314
+ < Suspense fallback = { < LoadingShimmer /> } >
315
+ < Show when = { ! ! debouncedSearchValue ( ) } >
316
+ < h2 class = "py-2 text-xl font-semibold" >
317
+ Global Search
318
+ </ h2 >
319
+ < GlobalSearch
320
+ searchValue = { debouncedSearchValue ( ) }
321
+ sendToContact = { sendToContact }
322
+ foundNpubs = { foundNpubs ( ) }
323
+ />
324
+ </ Show >
325
+ </ Suspense >
326
+ < div class = "h-4" />
327
+ </ div >
328
+ </ Show >
318
329
</ >
319
330
) ;
320
331
}
0 commit comments