@@ -51,15 +51,22 @@ export const ShareSettings = ({
5151 const pathname = usePathname ( ) ;
5252 const isAuthenticated = ! ! currentUser ;
5353
54- const handleCopyLink = useCallback ( ( ) => {
55- navigator . clipboard . writeText ( window . location . href ) ;
56- captureEvent ( 'wa_chat_link_copied' , {
57- chatId,
58- visibility,
59- } ) ;
60- toast ( {
61- description : "✅ Link copied to clipboard" ,
62- } ) ;
54+ const handleCopyLink = useCallback ( async ( ) => {
55+ try {
56+ await navigator . clipboard . writeText ( window . location . href ) ;
57+ captureEvent ( 'wa_chat_link_copied' , {
58+ chatId,
59+ visibility,
60+ } ) ;
61+ toast ( {
62+ description : "✅ Link copied to clipboard" ,
63+ } ) ;
64+ } catch ( e ) {
65+ toast ( {
66+ description : `Failed to copy link: ${ e instanceof Error ? e . message : "Unknown error" } ` ,
67+ variant : "destructive" ,
68+ } ) ;
69+ }
6370 } , [ chatId , visibility , toast ] ) ;
6471
6572 const getInitials = ( name ?: string | null , email ?: string | null ) => {
@@ -147,12 +154,16 @@ export const ShareSettings = ({
147154 disabled = { removingUserIds . has ( user . id ) }
148155 onClick = { async ( ) => {
149156 setRemovingUserIds ( prev => new Set ( prev ) . add ( user . id ) ) ;
150- await onRemoveSharedWithUser ( user . id ) ;
151- setRemovingUserIds ( prev => {
152- const next = new Set ( prev ) ;
153- next . delete ( user . id ) ;
154- return next ;
155- } ) ;
157+ try {
158+
159+ await onRemoveSharedWithUser ( user . id ) ;
160+ } finally {
161+ setRemovingUserIds ( prev => {
162+ const next = new Set ( prev ) ;
163+ next . delete ( user . id ) ;
164+ return next ;
165+ } ) ;
166+ }
156167 } }
157168 >
158169 { removingUserIds . has ( user . id ) ? (
@@ -187,8 +198,11 @@ export const ShareSettings = ({
187198 value = { visibility }
188199 onValueChange = { async ( value ) => {
189200 setIsVisibilityUpdating ( true ) ;
190- await onVisibilityChange ( value as ChatVisibility ) ;
191- setIsVisibilityUpdating ( false ) ;
201+ try {
202+ await onVisibilityChange ( value as ChatVisibility ) ;
203+ } finally {
204+ setIsVisibilityUpdating ( false ) ;
205+ }
192206 } }
193207 disabled = { isVisibilityUpdating || ! isAuthenticated }
194208 >
0 commit comments