diff --git a/src/management-system-v2/components/modeler-share-modal.tsx b/src/management-system-v2/components/modeler-share-modal.tsx index 7c7daa28e..b711ec63d 100644 --- a/src/management-system-v2/components/modeler-share-modal.tsx +++ b/src/management-system-v2/components/modeler-share-modal.tsx @@ -54,6 +54,18 @@ const ModelerShareModalButton: FC = ({ onExport, onExportMobile setActiveIndex(index); }; + const shareWrapper = async (fn: (args: any) => Promise, args: any) => { + try { + if (isSharing) return; + setIsSharing(true); + await fn(args); + } catch (error) { + console.error('Sharing failed:', error); + } finally { + setIsSharing(false); + } + }; + const handleShareMobile = async (sharedAs: 'public' | 'protected') => { if (navigator.share) { try { @@ -79,13 +91,13 @@ const ModelerShareModalButton: FC = ({ onExport, onExportMobile optionIcon: , optionName: 'Share Process with Public Link', optionTitle: 'Share Process with Public Link', - optionOnClick: () => handleShareMobile('public'), + optionOnClick: () => shareWrapper(handleShareMobile, 'public'), }, { optionIcon: , optionName: 'Share Process for Registered Users', optionTitle: 'Share Process for Registered Users', - optionOnClick: () => handleShareMobile('protected'), + optionOnClick: () => shareWrapper(handleShareMobile, 'protected'), }, { optionIcon: , @@ -97,16 +109,11 @@ const ModelerShareModalButton: FC = ({ onExport, onExportMobile optionIcon: , optionName: 'Share Process as Image', optionTitle: 'Share Process as Image', - optionOnClick: async () => { - if (isSharing) return; - setIsSharing(true); - await shareProcessImage(modeler); - setIsSharing(false); - }, + optionOnClick: () => shareWrapper(shareProcessImage, modeler), }, { optionIcon: ( - Follow us on Twitter + proceed logo ), optionName: 'Share Process as BPMN File', optionTitle: 'Share Process as BPMN File',