From a562cbeb255790e417bbf72c6848da8311a5c748 Mon Sep 17 00:00:00 2001 From: Astrid Date: Wed, 31 Jan 2024 22:22:07 +0100 Subject: [PATCH 1/8] Proper onClick types and give the callback --- src/components/buttons/Button.tsx | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/components/buttons/Button.tsx b/src/components/buttons/Button.tsx index 70e2c780..1c1a2b61 100644 --- a/src/components/buttons/Button.tsx +++ b/src/components/buttons/Button.tsx @@ -7,7 +7,9 @@ import { Spinner } from "@/components/layout/Spinner"; interface Props { icon?: Icons; - onClick?: () => void; + onClick?: ( + event: React.MouseEvent, + ) => void; children?: ReactNode; theme?: "white" | "purple" | "secondary" | "danger"; padding?: string; @@ -21,11 +23,19 @@ interface Props { export function Button(props: Props) { const navigate = useNavigate(); const { onClick, href, loading } = props; - const cb = useCallback(() => { - if (loading) return; - if (href) navigate(href); - else onClick?.(); - }, [onClick, href, navigate, loading]); + const cb = useCallback( + ( + event: React.MouseEvent< + HTMLAnchorElement | HTMLButtonElement, + MouseEvent + >, + ) => { + if (loading) return; + if (href && !onClick) navigate(href); + else onClick?.(event); + }, + [onClick, href, navigate, loading], + ); let colorClasses = "bg-white hover:bg-gray-200 text-black"; if (props.theme === "purple") @@ -80,6 +90,7 @@ export function Button(props: Props) { target="_blank" rel="noreferrer" download={props.download} + onClick={cb} > {content} From 71ddbca657374a46c42def879e8ae79c19fb56b5 Mon Sep 17 00:00:00 2001 From: Astrid Date: Wed, 31 Jan 2024 22:22:26 +0100 Subject: [PATCH 2/8] Copy playlist link instead of download playlist --- src/components/player/atoms/settings/Downloads.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/player/atoms/settings/Downloads.tsx b/src/components/player/atoms/settings/Downloads.tsx index 45c97997..5eb7d798 100644 --- a/src/components/player/atoms/settings/Downloads.tsx +++ b/src/components/player/atoms/settings/Downloads.tsx @@ -69,7 +69,17 @@ export function DownloadView({ id }: { id: string }) { -