Connection expiration
- {!isNew && (
+ {!isNewConnection && (
Expires:{" "}
{permissions.expiresAt &&
diff --git a/frontend/src/components/SuggestedApps.tsx b/frontend/src/components/SuggestedApps.tsx
index 100790ce..77d52c24 100644
--- a/frontend/src/components/SuggestedApps.tsx
+++ b/frontend/src/components/SuggestedApps.tsx
@@ -9,7 +9,7 @@ import { SuggestedApp, suggestedApps } from "./SuggestedAppData";
function SuggestedAppCard({ id, title, description, logo }: SuggestedApp) {
return (
-
+
diff --git a/frontend/src/components/ui/carousel.tsx b/frontend/src/components/ui/carousel.tsx
index 6b5b016f..61b1eb80 100644
--- a/frontend/src/components/ui/carousel.tsx
+++ b/frontend/src/components/ui/carousel.tsx
@@ -255,6 +255,7 @@ const CarouselDots = React.forwardRef<
React.HTMLAttributes
>((props, ref) => {
const { api } = useCarousel();
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_, setUpdateState] = React.useState(false);
const toggleUpdateState = React.useCallback(
() => setUpdateState((prevState) => !prevState),
diff --git a/frontend/src/components/ui/loading-button.tsx b/frontend/src/components/ui/loading-button.tsx
index 3a591bb1..fb45e672 100644
--- a/frontend/src/components/ui/loading-button.tsx
+++ b/frontend/src/components/ui/loading-button.tsx
@@ -70,4 +70,5 @@ const LoadingButton = React.forwardRef(
);
LoadingButton.displayName = "LoadingButton";
+// eslint-disable-next-line react-refresh/only-export-components
export { LoadingButton, buttonVariants };
diff --git a/frontend/src/components/ui/use-toast.ts b/frontend/src/components/ui/use-toast.ts
index 77f18c46..cff338fb 100644
--- a/frontend/src/components/ui/use-toast.ts
+++ b/frontend/src/components/ui/use-toast.ts
@@ -154,7 +154,9 @@ function toast({ ...props }: Toast) {
id,
open: true,
onOpenChange: (open) => {
- if (!open) dismiss();
+ if (!open) {
+ dismiss();
+ }
},
},
});
diff --git a/frontend/src/screens/apps/AppCreated.tsx b/frontend/src/screens/apps/AppCreated.tsx
index 5bfa778f..79f0ec8f 100644
--- a/frontend/src/screens/apps/AppCreated.tsx
+++ b/frontend/src/screens/apps/AppCreated.tsx
@@ -1,26 +1,66 @@
-import { DialogDescription, DialogTrigger } from "@radix-ui/react-dialog";
-import { CopyIcon, QrCode } from "lucide-react";
-import { useEffect } from "react";
-import { Navigate, useLocation } from "react-router-dom";
+import { CopyIcon } from "lucide-react";
+import { useEffect, useState } from "react";
+import { Link, Navigate, useLocation, useNavigate } from "react-router-dom";
+import AppHeader from "src/components/AppHeader";
+import ExternalLink from "src/components/ExternalLink";
+import Loading from "src/components/Loading";
import QRCode from "src/components/QRCode";
+import { suggestedApps } from "src/components/SuggestedAppData";
import { Button } from "src/components/ui/button";
import {
- Dialog,
- DialogContent,
- DialogHeader,
- DialogTitle,
-} from "src/components/ui/dialog";
+ Card,
+ CardContent,
+ CardHeader,
+ CardTitle,
+} from "src/components/ui/card";
import { useToast } from "src/components/ui/use-toast";
+import { useApp } from "src/hooks/useApp";
import { copyToClipboard } from "src/lib/clipboard";
import { CreateAppResponse } from "src/types";
export default function AppCreated() {
- const { state } = useLocation();
+ const { search, state } = useLocation();
+ const navigate = useNavigate();
const { toast } = useToast();
+
+ const queryParams = new URLSearchParams(search);
+ const appId = queryParams.get("app") ?? "";
+ const appstoreApp = suggestedApps.find((app) => app.id === appId);
+ console.info(appstoreApp, appId);
+
+ const [timeout, setTimeout] = useState(false);
const createAppResponse = state as CreateAppResponse;
+ const pairingUri = createAppResponse.pairingUri;
+ const { data: app } = useApp(createAppResponse.pairingPublicKey, true);
+
+ const copy = () => {
+ copyToClipboard(pairingUri);
+ toast({ title: "Copied to clipboard." });
+ };
+
+ useEffect(() => {
+ const timeoutId = window.setTimeout(() => {
+ setTimeout(true);
+ }, 10000);
+
+ return () => window.clearTimeout(timeoutId);
+ }, []);
+
+ useEffect(() => {
+ if (app?.lastEventAt) {
+ toast({
+ title: "Connection established!",
+ description: "You can now use the app with your Alby Hub.",
+ });
+ navigate("/apps");
+ }
+ }, [app?.lastEventAt, navigate, toast]);
useEffect(() => {
+ if (appstoreApp) {
+ return;
+ }
// dispatch a success event which can be listened to by the opener or by the app that embedded the webview
// this gives those apps the chance to know the user has enabled the connection
const nwcEvent = new CustomEvent("nwc:success", { detail: {} });
@@ -36,58 +76,72 @@ export default function AppCreated() {
"*"
);
}
- }, []);
+ }, [appstoreApp]);
if (!createAppResponse) {
return ;
}
- const pairingUri = createAppResponse.pairingUri;
-
- const copy = () => {
- copyToClipboard(pairingUri);
- toast({ title: "Copied to clipboard." });
- };
-
return (
-
-
- 🚀 Almost there!
-
-
- Complete the last step of the setup by pasting or scanning your
- connection's pairing secret in the desired app to finalise the
- connection.
-
-
-
-
-