mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-14 15:15:22 +03:00
Handle cases where share is not available
This commit is contained in:
parent
a09cc787fb
commit
4cbabdcc39
@ -19,6 +19,7 @@ import { DeleteClipType, Export } from "@/types/export";
|
||||
import { MdEditSquare } from "react-icons/md";
|
||||
import { baseUrl } from "@/api/baseUrl";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { shareOrCopy } from "@/utils/browserUtil";
|
||||
|
||||
type ExportProps = {
|
||||
className: string;
|
||||
@ -151,10 +152,10 @@ export default function ExportCard({
|
||||
<Chip
|
||||
className="cursor-pointer rounded-md bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500"
|
||||
onClick={() =>
|
||||
navigator.share({
|
||||
url: `${baseUrl}exports?id=${exportedRecording.id}`,
|
||||
title: exportedRecording.name.replaceAll("_", " "),
|
||||
})
|
||||
shareOrCopy(
|
||||
`${baseUrl}exports?id=${exportedRecording.id}`,
|
||||
exportedRecording.name.replaceAll("_", " "),
|
||||
)
|
||||
}
|
||||
>
|
||||
<FaShareAlt className="size-4 text-white" />
|
||||
|
||||
@ -36,6 +36,7 @@ import {
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { baseUrl } from "@/api/baseUrl";
|
||||
import { shareOrCopy } from "@/utils/browserUtil";
|
||||
|
||||
type ReviewDetailDialogProps = {
|
||||
review?: ReviewSegment;
|
||||
@ -143,9 +144,7 @@ export default function ReviewDetailDialog({
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
navigator.share({
|
||||
url: `${baseUrl}review?id=${review.id}`,
|
||||
})
|
||||
shareOrCopy(`${baseUrl}review?id=${review.id}`)
|
||||
}
|
||||
>
|
||||
<FaShareAlt className="size-4" />
|
||||
|
||||
12
web/src/utils/browserUtil.ts
Normal file
12
web/src/utils/browserUtil.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import copy from "copy-to-clipboard";
|
||||
|
||||
export function shareOrCopy(url: string, title?: string) {
|
||||
if (window.isSecureContext && "share" in navigator) {
|
||||
navigator.share({
|
||||
url: url,
|
||||
title: title,
|
||||
});
|
||||
} else {
|
||||
copy(url);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user