Skip to content

Commit 2c2a1dd

Browse files
committed
refactor signature
1 parent 0ea55e7 commit 2c2a1dd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/components/Shared/CopyButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const CopyButton = ({ text, style = {}, ...buttonProps }: CopyButtonProps
1818
const { t } = useTranslation();
1919

2020
const handleCopy = async () => {
21-
await copyToClipboard(text, false);
21+
await copyToClipboard(text, { showToastOnSuccess: false });
2222
setActiveCopyId(uniqueId);
2323
};
2424

src/hooks/useCopyToClipboard.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import { useCallback } from 'react';
22
import { useToast } from '../context/ToastContext.tsx';
33
import { useTranslation } from 'react-i18next';
44

5-
export type CopyFn = (text: string, showToastOnSuccess?: boolean) => Promise<boolean>;
5+
export type CopyFn = (text: string, options?: { showToastOnSuccess: boolean }) => Promise<boolean>;
66

77
export function useCopyToClipboard(): { copyToClipboard: CopyFn } {
88
const toast = useToast();
99
const { t } = useTranslation();
1010

1111
const copyToClipboard: CopyFn = useCallback(
12-
async (text, showToastOnSuccess = true) => {
12+
async (text, options = { showToastOnSuccess: true }) => {
1313
if (!navigator.clipboard) {
1414
toast.show(t('common.copyToClipboardFailedToast'));
1515
return false;
1616
}
1717

1818
try {
1919
await navigator.clipboard.writeText(text);
20-
if (showToastOnSuccess) {
20+
if (options.showToastOnSuccess) {
2121
toast.show(t('common.copyToClipboardSuccessToast'));
2222
}
2323
return true;

0 commit comments

Comments
 (0)