fix share link display

This commit is contained in:
ppc
2024-08-22 10:10:43 +01:00
parent 401c011b0c
commit 1a1a5ba73b
+24 -21
View File
@@ -37,7 +37,7 @@ async function performCardInAction(card: AimeCard, server: AimeServer, setCardIn
try {
const abort = new AbortController();
setTimeout(() => abort.abort("timeout"), 10000);
await performCardIn(server.serverAddress, {cardId: card.id}, abort.signal);
await db.cards.update(card.id, {lastUsed: Date.now()});
@@ -153,8 +153,9 @@ function ServerCardInPage() {
</AMHeader>
{!server && (<LoadingIndicator/>)}
{(server && connectionError)
? <Alert variant="destructive">
{(server && !connectionError) && <IncognitoStorageWarning/>}
{(server && connectionError) && (
<Alert variant="destructive">
<WifiOff className="h-4 w-4"/>
<AlertTitle>Connection Issue</AlertTitle>
<AlertDescription>
@@ -164,7 +165,7 @@ function ServerCardInPage() {
onClick={() => setServerReloadCounter(serverReloadCounter + 1)}>try again</span>.
</AlertDescription>
</Alert>
: <IncognitoStorageWarning/>}
)}
{server && (
<div className="flex flex-col gap-4 w-full flex-grow">
@@ -201,23 +202,25 @@ function ServerCardInPage() {
className="flex flex-col-reverse sm:flex-row sm:flex-wrap justify-center sm:justify-between sm:gap-2 gap-4">
{server?.id && (
<div className="flex items-center justify-center sm:gap-5 gap-2">
{location.protocol === "https:" && navigator.share ? (
<p className="text-sm text-blue-500" role="button"
onClick={() => navigator.share({url: shareUrl})}>
Share
</p>
) : (
<p className="text-sm text-blue-500" role="button"
onClick={() => navigator.clipboard.writeText(shareUrl).then(() => {
toast({
description: "Server URL has been copied to clipboard.",
duration: 2500
})
})}>
Copy URL
</p>
)}
<Separator orientation="vertical"/>
{location.protocol === "https:" && (<>
{navigator.share ? (
<p className="text-sm text-blue-500" role="button"
onClick={() => navigator.share({url: shareUrl})}>
Share
</p>
) : (
<p className="text-sm text-blue-500" role="button"
onClick={() => navigator.clipboard.writeText(shareUrl).then(() => {
toast({
description: "Server URL has been copied to clipboard.",
duration: 2500
})
})}>
Copy URL
</p>)}
<Separator orientation="vertical"/>
</>)}
<AlertDialog>
<AlertDialogTrigger>
<p className="text-sm text-red-700">Delete {server.serverName}</p>