1
1
import { Globe } from "lucide-react" ;
2
2
import React from "react" ;
3
- import { Link } from "react-router-dom" ;
3
+ import { Link , useNavigate } from "react-router-dom" ;
4
4
import AppHeader from "src/components/AppHeader" ;
5
5
import ExternalLink from "src/components/ExternalLink" ;
6
6
import { AppleIcon } from "src/components/icons/Apple" ;
@@ -32,21 +32,17 @@ import { Input } from "src/components/ui/input";
32
32
import { Label } from "src/components/ui/label" ;
33
33
import { LoadingButton } from "src/components/ui/loading-button" ;
34
34
import { useToast } from "src/components/ui/use-toast" ;
35
- import { useApp } from "src/hooks/useApp" ;
36
35
import { useCapabilities } from "src/hooks/useCapabilities" ;
37
36
import { createApp } from "src/requests/createApp" ;
38
- import { ConnectAppCard } from "src/screens/apps/AppCreated" ;
39
37
40
38
export function AlbyGo ( ) {
41
39
const [ loading , setLoading ] = React . useState ( false ) ;
42
- const [ appPubkey , setAppPubkey ] = React . useState < string > ( ) ;
43
- const [ connectionSecret , setConnectionSecret ] = React . useState < string > ( "" ) ;
44
40
const [ unlockPassword , setUnlockPassword ] = React . useState ( "" ) ;
45
41
const [ showCreateConnectionDialog , setShowCreateConnectionDialog ] =
46
42
React . useState ( false ) ;
47
- const { data : createdApp } = useApp ( appPubkey , true ) ;
48
43
const { toast } = useToast ( ) ;
49
44
const { data : capabilities } = useCapabilities ( ) ;
45
+ const navigate = useNavigate ( ) ;
50
46
51
47
const app = suggestedApps . find ( ( app ) => app . id === "alby-go" ) ;
52
48
if ( ! app ) {
@@ -61,6 +57,9 @@ export function AlbyGo() {
61
57
e . preventDefault ( ) ;
62
58
setLoading ( true ) ;
63
59
try {
60
+ if ( ! app ) {
61
+ throw new Error ( "Alby go app not found" ) ;
62
+ }
64
63
if ( ! capabilities ) {
65
64
throw new Error ( "capabilities not loaded" ) ;
66
65
}
@@ -71,14 +70,15 @@ export function AlbyGo() {
71
70
scopes : [ ...capabilities . scopes , "superuser" ] ,
72
71
isolated : false ,
73
72
metadata : {
74
- app_store_app_id : "alby-go" ,
73
+ app_store_app_id : app . id ,
75
74
} ,
76
75
unlockPassword,
77
76
maxAmount : 100_000 ,
78
77
budgetRenewal : "monthly" ,
79
78
} ) ;
80
- setConnectionSecret ( createAppResponse . pairingUri ) ;
81
- setAppPubkey ( createAppResponse . pairingPublicKey ) ;
79
+ navigate ( `/apps/created?app=${ app . id } ` , {
80
+ state : createAppResponse ,
81
+ } ) ;
82
82
toast ( { title : "Alby Go connection created" } ) ;
83
83
} catch ( error ) {
84
84
console . error ( error ) ;
@@ -167,14 +167,12 @@ export function AlbyGo() {
167
167
}
168
168
description = ""
169
169
contentRight = {
170
- ! createdApp && (
171
- < Link to = { `/apps/new?app=${ app . id } ` } >
172
- < Button >
173
- < NostrWalletConnectIcon className = "w-4 h-4 mr-2" />
174
- Connect to { app . title }
175
- </ Button >
176
- </ Link >
177
- )
170
+ < Link to = { `/apps/new?app=${ app . id } ` } >
171
+ < Button >
172
+ < NostrWalletConnectIcon className = "w-4 h-4 mr-2" />
173
+ Connect to { app . title }
174
+ </ Button >
175
+ </ Link >
178
176
}
179
177
/>
180
178
< div className = "grid grid-cols-1 md:grid-cols-2 gap-6" >
@@ -298,30 +296,24 @@ export function AlbyGo() {
298
296
</ CardFooter >
299
297
</ Card >
300
298
) }
301
- { createdApp && connectionSecret && (
302
- < div className = "mb-16 w-full" >
303
- < ConnectAppCard app = { createdApp } pairingUri = { connectionSecret } />
304
- </ div >
305
- ) }
306
- { ! createdApp && (
307
- < Card >
308
- < CardHeader >
309
- < CardTitle className = "text-2xl" > One Tap Connections</ CardTitle >
310
- </ CardHeader >
311
- < CardContent >
312
- < p className = "text-muted-foreground" >
313
- Use Alby Go to quickly connect other apps to your hub with one
314
- tap on mobile.
315
- </ p >
316
- {
317
- < Button className = "mt-8" onClick = { onClickCreateConnection } >
318
- < NostrWalletConnectIcon className = "w-4 h-4 mr-2" />
319
- Connect with One Tap Connections
320
- </ Button >
321
- }
322
- </ CardContent >
323
- </ Card >
324
- ) }
299
+
300
+ < Card >
301
+ < CardHeader >
302
+ < CardTitle className = "text-2xl" > One Tap Connections</ CardTitle >
303
+ </ CardHeader >
304
+ < CardContent >
305
+ < p className = "text-muted-foreground" >
306
+ Use Alby Go to quickly connect other apps to your hub with one
307
+ tap on mobile.
308
+ </ p >
309
+ {
310
+ < Button className = "mt-8" onClick = { onClickCreateConnection } >
311
+ < NostrWalletConnectIcon className = "w-4 h-4 mr-2" />
312
+ Connect with One Tap Connections
313
+ </ Button >
314
+ }
315
+ </ CardContent >
316
+ </ Card >
325
317
</ div >
326
318
</ div >
327
319
</ div >
0 commit comments