stream-chat-react-native icon indicating copy to clipboard operation
stream-chat-react-native copied to clipboard

Removed File reappears in the fileUploads array

Open vinaygregoryjohn183 opened this issue 2 years ago • 2 comments

Describe the bug have a use case where i want to remove a file which was selected from the attachment picker. I tried calling the removeFile() provided by the MessageInputContext. Once I call it the file gets deleted from the fileUploads but somehow reappears in the fileUploads array (fileUploads- provided by the MessageInputContext). How does this happen as I'm not manually re-selecting the removed file?PS: removeImage() is working fine. But removeFile() doesn't. My code: const MessageInputComponent = () => { const { toggleAttachmentPicker, imageUploads, removeImage, fileUploads, removeFile } = useMessageInputContext();

// Working fine useEffect(() => { removeImage(imageUploads[0]?.id); }, [imageUploads, removeImage]);

// Not working (the removed file reappears in the fileUploads array) useEffect(() => { removeFile(fileUploads[0]?.id); }, [fileUploads, removeFile]);

Screenshot 2022-06-14 at 10 29 36 AM

Dev environment info (please complete/provide the following information): Package Versions: "react-native": "0.66.4", "stream-chat": "^6.3.0", "stream-chat-react-native": "^4.6.1”

Expected behavior The removed file should not reappear in the fileUploads array provided by stream's MessageInputContext.

vinaygregoryjohn183 avatar Jun 14 '22 04:06 vinaygregoryjohn183

Hi @vinaygregoryjohn183, thanks for reaching out. I've managed to reproduce this issue.

After removing the file, the file is not visible in the MessageInput component yet present in the fileUploads array originating from useMessageInputContext.

We might be over-memoizing something or setting the state twice. We will take a look at it. You can keep on following this issue for any updates.

Out of curiosity, what impact does it have on you and your users if the UI works as expected?

vanGalilea avatar Jun 21 '22 07:06 vanGalilea

Hey team! Please add your planning poker estimate with ZenHub @Enigma-I-am @khushal87 @madsroskar

vanGalilea avatar Jun 21 '22 08:06 vanGalilea

Out of curiosity, what impact does it have on you and your users if the UI works as expected?

@vinaygregoryjohn183 is this still an issue? A lot has changed in our SDK still this issue was created

vanGalilea avatar Mar 08 '23 14:03 vanGalilea

This issue became stale. I'll be closing this issue for now. Please don't hesitate to contact us in the future if this issue or any questions arise.

vanGalilea avatar May 12 '23 07:05 vanGalilea