mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(post-menu): await clipboard copy before closing menu
This commit is contained in:
@@ -21,9 +21,14 @@ const CopyLinkButton = ({ cid, subplebbitAddress, linkType, onClose }: { cid?: s
|
||||
const boardIdentifier = getBoardPath(subplebbitAddress, defaultSubplebbits);
|
||||
return (
|
||||
<div
|
||||
onClick={() => {
|
||||
copyShareLinkToClipboard(boardIdentifier, linkType, cid);
|
||||
onClose();
|
||||
onClick={async () => {
|
||||
try {
|
||||
await copyShareLinkToClipboard(boardIdentifier, linkType, cid);
|
||||
} catch (error) {
|
||||
console.error('Failed to copy share link', error);
|
||||
} finally {
|
||||
onClose();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className={styles.postMenuItem}>{t('copy_link')}</div>
|
||||
@@ -35,9 +40,14 @@ const CopyContentIdButton = ({ cid, onClose }: { cid: string; onClose: () => voi
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div
|
||||
onClick={() => {
|
||||
copyToClipboard(cid);
|
||||
onClose();
|
||||
onClick={async () => {
|
||||
try {
|
||||
await copyToClipboard(cid);
|
||||
} catch (error) {
|
||||
console.error('Failed to copy content id', error);
|
||||
} finally {
|
||||
onClose();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className={styles.postMenuItem}>{t('copy_content_id')}</div>
|
||||
|
||||
@@ -29,9 +29,14 @@ const CopyLinkButton = ({ cid, subplebbitAddress, linkType, onClose }: { cid?: s
|
||||
const boardIdentifier = getBoardPath(subplebbitAddress, defaultSubplebbits);
|
||||
return (
|
||||
<div
|
||||
onClick={() => {
|
||||
copyShareLinkToClipboard(boardIdentifier, linkType, cid);
|
||||
onClose();
|
||||
onClick={async () => {
|
||||
try {
|
||||
await copyShareLinkToClipboard(boardIdentifier, linkType, cid);
|
||||
} catch (error) {
|
||||
console.error('Failed to copy share link', error);
|
||||
} finally {
|
||||
onClose();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className={styles.postMenuItem}>{t('copy_link')}</div>
|
||||
@@ -43,9 +48,14 @@ const CopyContentIdButton = ({ cid, onClose }: { cid: string; onClose: () => voi
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div
|
||||
onClick={() => {
|
||||
copyToClipboard(cid);
|
||||
onClose();
|
||||
onClick={async () => {
|
||||
try {
|
||||
await copyToClipboard(cid);
|
||||
} catch (error) {
|
||||
console.error('Failed to copy content id', error);
|
||||
} finally {
|
||||
onClose();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className={styles.postMenuItem}>{t('copy_content_id')}</div>
|
||||
|
||||
Reference in New Issue
Block a user