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 { MdEditSquare } from "react-icons/md";
|
||||||
import { baseUrl } from "@/api/baseUrl";
|
import { baseUrl } from "@/api/baseUrl";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
import { shareOrCopy } from "@/utils/browserUtil";
|
||||||
|
|
||||||
type ExportProps = {
|
type ExportProps = {
|
||||||
className: string;
|
className: string;
|
||||||
@ -151,10 +152,10 @@ export default function ExportCard({
|
|||||||
<Chip
|
<Chip
|
||||||
className="cursor-pointer rounded-md bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500"
|
className="cursor-pointer rounded-md bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
navigator.share({
|
shareOrCopy(
|
||||||
url: `${baseUrl}exports?id=${exportedRecording.id}`,
|
`${baseUrl}exports?id=${exportedRecording.id}`,
|
||||||
title: exportedRecording.name.replaceAll("_", " "),
|
exportedRecording.name.replaceAll("_", " "),
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<FaShareAlt className="size-4 text-white" />
|
<FaShareAlt className="size-4 text-white" />
|
||||||
|
|||||||
@ -36,6 +36,7 @@ import {
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { baseUrl } from "@/api/baseUrl";
|
import { baseUrl } from "@/api/baseUrl";
|
||||||
|
import { shareOrCopy } from "@/utils/browserUtil";
|
||||||
|
|
||||||
type ReviewDetailDialogProps = {
|
type ReviewDetailDialogProps = {
|
||||||
review?: ReviewSegment;
|
review?: ReviewSegment;
|
||||||
@ -143,9 +144,7 @@ export default function ReviewDetailDialog({
|
|||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
navigator.share({
|
shareOrCopy(`${baseUrl}review?id=${review.id}`)
|
||||||
url: `${baseUrl}review?id=${review.id}`,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<FaShareAlt className="size-4" />
|
<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