@@ -292,6 +292,7 @@ const MessageInputWithContext = <
292292 useEffect ( ( ) => {
293293 if ( imagesForInput ) {
294294 if ( selectedImagesLength > imageUploadsLength ) {
295+ /** User selected an image in bottom sheet attachment picker */
295296 const imagesToUpload = selectedImages . filter ( ( selectedImage ) => {
296297 const uploadedImage = imageUploads . find (
297298 ( imageUpload ) =>
@@ -301,6 +302,7 @@ const MessageInputWithContext = <
301302 } ) ;
302303 imagesToUpload . forEach ( ( image ) => uploadNewImage ( image ) ) ;
303304 } else if ( selectedImagesLength < imageUploadsLength ) {
305+ /** User de-selected an image in bottom sheet attachment picker */
304306 const imagesToRemove = imageUploads . filter (
305307 ( imageUpload ) =>
306308 ! selectedImages . find (
@@ -316,6 +318,7 @@ const MessageInputWithContext = <
316318 useEffect ( ( ) => {
317319 if ( imagesForInput ) {
318320 if ( imageUploadsLength < selectedImagesLength ) {
321+ /** User removed some image from seleted images within ImageUploadPreview. */
319322 const updatedSelectedImages = selectedImages . filter ( ( selectedImage ) => {
320323 const uploadedImage = imageUploads . find (
321324 ( imageUpload ) =>
@@ -325,12 +328,17 @@ const MessageInputWithContext = <
325328 } ) ;
326329 setSelectedImages ( updatedSelectedImages ) ;
327330 } else if ( imageUploadsLength > selectedImagesLength ) {
331+ /**
332+ * User is editing some message which contains image attachments OR
333+ * image attachment is added from custom image picker (other than the default bottomsheet image picker)
334+ * using `uploadNewImage` function from `MessageInputContext`.
335+ **/
328336 setSelectedImages (
329337 imageUploads
330338 . map ( ( imageUpload ) => ( {
331339 height : imageUpload . file . height ,
332340 source : imageUpload . file . source ,
333- uri : imageUpload . url ,
341+ uri : imageUpload . url || imageUpload . file . uri ,
334342 width : imageUpload . file . width ,
335343 } ) )
336344 . filter ( Boolean ) as Asset [ ] ,
0 commit comments