@@ -1203,15 +1203,18 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
12031203 if ( updatedMessage . attachments ?. length ) {
12041204 for ( let i = 0 ; i < updatedMessage . attachments ?. length ; i ++ ) {
12051205 const attachment = updatedMessage . attachments [ i ] ;
1206- const image = attachment . originalFile ;
1207- const file = attachment . originalFile ;
1208- // check if image_url is not a remote url
1206+
1207+ // If the attachment is already uploaded, skip it.
12091208 if (
1210- attachment . type === FileTypes . Image &&
1211- image ?. uri &&
1212- attachment . image_url &&
1213- isLocalUrl ( attachment . image_url )
1209+ ( attachment . image_url && ! isLocalUrl ( attachment . image_url ) ) ||
1210+ ( attachment . asset_url && ! isLocalUrl ( attachment . asset_url ) )
12141211 ) {
1212+ continue ;
1213+ }
1214+
1215+ const image = attachment . originalFile ;
1216+ const file = attachment . originalFile ;
1217+ if ( attachment . type === FileTypes . Image && image ?. uri ) {
12151218 const filename = image . name ?? getFileNameFromPath ( image . uri ) ;
12161219 // if any upload is in progress, cancel it
12171220 const controller = uploadAbortControllerRef . current . get ( filename ) ;
@@ -1234,12 +1237,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
12341237 } ) ;
12351238 }
12361239
1237- if (
1238- attachment . type !== FileTypes . Image &&
1239- attachment . asset_url &&
1240- isLocalUrl ( attachment . asset_url ) &&
1241- file ?. uri
1242- ) {
1240+ if ( attachment . type !== FileTypes . Image && file ?. uri ) {
12431241 // if any upload is in progress, cancel it
12441242 const controller = uploadAbortControllerRef . current . get ( file . name ) ;
12451243 if ( controller ) {
0 commit comments