Skip to content

Commit fb3de53

Browse files
authored
fix: redirect to app created page after creating alby go app with one tap connections (#1148)
1 parent eeba63c commit fb3de53

File tree

1 file changed

+33
-41
lines changed

1 file changed

+33
-41
lines changed

frontend/src/screens/internal-apps/AlbyGo.tsx

+33-41
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Globe } from "lucide-react";
22
import React from "react";
3-
import { Link } from "react-router-dom";
3+
import { Link, useNavigate } from "react-router-dom";
44
import AppHeader from "src/components/AppHeader";
55
import ExternalLink from "src/components/ExternalLink";
66
import { AppleIcon } from "src/components/icons/Apple";
@@ -32,21 +32,17 @@ import { Input } from "src/components/ui/input";
3232
import { Label } from "src/components/ui/label";
3333
import { LoadingButton } from "src/components/ui/loading-button";
3434
import { useToast } from "src/components/ui/use-toast";
35-
import { useApp } from "src/hooks/useApp";
3635
import { useCapabilities } from "src/hooks/useCapabilities";
3736
import { createApp } from "src/requests/createApp";
38-
import { ConnectAppCard } from "src/screens/apps/AppCreated";
3937

4038
export function AlbyGo() {
4139
const [loading, setLoading] = React.useState(false);
42-
const [appPubkey, setAppPubkey] = React.useState<string>();
43-
const [connectionSecret, setConnectionSecret] = React.useState<string>("");
4440
const [unlockPassword, setUnlockPassword] = React.useState("");
4541
const [showCreateConnectionDialog, setShowCreateConnectionDialog] =
4642
React.useState(false);
47-
const { data: createdApp } = useApp(appPubkey, true);
4843
const { toast } = useToast();
4944
const { data: capabilities } = useCapabilities();
45+
const navigate = useNavigate();
5046

5147
const app = suggestedApps.find((app) => app.id === "alby-go");
5248
if (!app) {
@@ -61,6 +57,9 @@ export function AlbyGo() {
6157
e.preventDefault();
6258
setLoading(true);
6359
try {
60+
if (!app) {
61+
throw new Error("Alby go app not found");
62+
}
6463
if (!capabilities) {
6564
throw new Error("capabilities not loaded");
6665
}
@@ -71,14 +70,15 @@ export function AlbyGo() {
7170
scopes: [...capabilities.scopes, "superuser"],
7271
isolated: false,
7372
metadata: {
74-
app_store_app_id: "alby-go",
73+
app_store_app_id: app.id,
7574
},
7675
unlockPassword,
7776
maxAmount: 100_000,
7877
budgetRenewal: "monthly",
7978
});
80-
setConnectionSecret(createAppResponse.pairingUri);
81-
setAppPubkey(createAppResponse.pairingPublicKey);
79+
navigate(`/apps/created?app=${app.id}`, {
80+
state: createAppResponse,
81+
});
8282
toast({ title: "Alby Go connection created" });
8383
} catch (error) {
8484
console.error(error);
@@ -167,14 +167,12 @@ export function AlbyGo() {
167167
}
168168
description=""
169169
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>
178176
}
179177
/>
180178
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
@@ -298,30 +296,24 @@ export function AlbyGo() {
298296
</CardFooter>
299297
</Card>
300298
)}
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>
325317
</div>
326318
</div>
327319
</div>

0 commit comments

Comments
 (0)