Closed jboniface closed 2 years ago
Invited two contributors to accept offer on Upwork
Hi, I've looked through the code and have a few methods of implementation. Both include me writing a function that gets the next attachment from the sorted actions array.
How I pass that function down to the attachment modal has 2 possibilities. Either I pass the function down through the action object, the HTML component and into the attachment modal or I write a react context and attempt to bypass all the unnecessary prop definitions.
Another update. Seems the react-native-render-html module doesn't work when passing props to renderers for some reason. the passProps value is always undefined.
Could i ask why "react-native-render-html": "^6.0.0-alpha.10", is being used? it seems to be missing a lot of features of the current v5 code.
Hi, @ThatOneAwkwardGuy you can see more of the context around that upgrade in this PR: https://github.com/Expensify/Expensify.cash/pull/882 I hope that helps!
At this point, it's not, no. We haven't developed best practices for using hooks yet, and until we do that we would like to avoid using them.
I'm reading up more about this issue so that I'm more familiar with the proposal being discussed. It seems that the modal itself needs access to the report actions array (specifically the actions that are attachments isAttachment === true
). The attachment modal can access those actions from Onyx the same as is being done in the header here. It looks like all that is needed is to pass the reportID
to the AttachmentModal
inside ReportActionCompose.js
and then add a new key to withOnyx()
in AttachmentModal.js
.
That will allow the modal to access all the report actions without needing to use hooks or to do a lot of prop-drilling. Does that help at all?
At this point, it's not, no. We haven't developed best practices for using hooks yet, and until we do that we would like to avoid using them.
I'm reading up more about this issue so that I'm more familiar with the proposal being discussed. It seems that the modal itself needs access to the report actions array (specifically the actions that are attachments
isAttachment === true
). The attachment modal can access those actions from Onyx the same as is being done in the header here. It looks like all that is needed is to pass thereportID
to theAttachmentModal
insideReportActionCompose.js
and then add a new key towithOnyx()
inAttachmentModal.js
.That will allow the modal to access all the report actions without needing to use hooks or to do a lot of prop-drilling. Does that help at all?
Yes it really does, I was going through all m ideas on getting the actions array to the Modal
After playing around with the code more, there is a problem with the structure of the components. I've written a function that gets the next attachment and cycles around if there aren't any more at the end of the list.
However, the problem is that the attachments provide HTML which is passed to renderHTML. since any change in the fragment (i.e swapping it out for the next one) will cause a re-render of the renderHTML component there will also be a rerender of the AttachmentModal which is inside the renderHTML component. I'll attempt to refactor the code so that there is a singular modal for rendering attachments and it is outside of the entire flatlist of actions.
Completed my solution, just cleaning up the code. Hopefully, you'll find it acceptable. Had to move the Attachment Modal to ReportActionsView and pass a function to the TouchableOpacity wrapping the attachments you can click to then launch the modal with the necessary data to display on the modal. Happy to answer any questions once I have the code pushed
Hi, So I have implemented a solution as follows: Made a functional component and beside this used 2 modules i.e. react native crop image picker and react native carousel and call this functional component in the developed screen to select images and review them
@HasaanA16 I've got a few questions about your proposed solution:
The functional component I propose allows the user to click on the paper click icon where he will see the option of selecting image from the device. Copy the code from my proposed solution and update your component with it.
From react-native-image-crop picker I used the functionality to select multiple images and save their record too as other modules doesn't provide this functionality.
I intended to use the carousel but I didn't. I just used a ScrollList which will show all the images we have selected to preview them when the user swipe right or left
From react-native-image-crop picker I used the functionality to select multiple images and save their record too as other modules doesn't provide this functionality.
It looks like this issue is for enabling a user to cycle through already uploaded attachments via the existing AttachmentModal, so I don't think we need to add another image picker (we're already using an AttachmentPicker).
I just used a ScrollList which will show all the images we have selected to preview them when the user swipe right or left
This sounds like you're updating the attachment picker component to be able to scroll through just the attachments that were selected by an image picker after clicking the paper clip icon. Just to confirm, will your ScrollList also enable users to click on an existing attachment in the chat, and then preview all other already existing attachments in the chat by using the arrow keys on web?
No, this ScrollList allows the user to preview and navigate through images before sending them. If you require I can update this component with a modal where user can preview while navigating already sent attachments.
If you require I can update this component with a modal where user can preview while navigating already sent attachments.
Yes, please provide a proposal for allowing the user to navigate between already existing attachments on the chat via the AttachmentModal. Updating the attachment picker to allow for multiple file uploads isn't necessary for this issue.
sure.! I am on it, will ping you in day or two with the changes that you require and hopefully you will like it.
I talked this over with @chiragsalian and I think he makes a good point that the carousel (i.e. cycling) behavior is unnecessary in this context, as there is unlikely to be a context where you need to loop back to the first image you ever uploaded. i think we can probably cut this behavior.
As you say so, its your call. So should I not make any changes to the code ? Also let me know if there is something I can do here.
To clarify, I just mean the part of the behavior where the attachments loop -- instead, when you are at the latest attachment in the chat, pressing right on your keyboard should not loop you to the first image you uploaded.
Leaving a quick summary of where we're at with suggested next steps for this issue…
This issue didn’t really have clear steps on how to complete it so there was a lot of back and forth on the best way to implement. Ultimately, we didn't feel that we had the best possible solution. But we do have a better idea of the scope of this issue and what kinds of problems we will face to solve it.
Problems
react-native-render-html
custom renderer. We had this ability but for some reason lost it when switching to the latest beta. We should first restore this ability before picking up this issue again. Not being able to pass props led to solutions that were more complicated than necessary.AttachmentModal
should probably be refactored before we ask anyone to work on this specific issue again. Suggested course of action:
react-native-render-html
maintainers and see if we can get the props to be passed to the custom renderer for the beta version we are on. If that's not possible, we should stop using a custom renderer and instead detect when we have an attachment and skip the RenderHTML
component.AttachmentModal
and an index to each attachment preview. This way we only need to track and set an "active index" for determining which attachment to display in the modal.I've used react-native-image-crop module which will allow user to select single or multiple attachment.. I've than used react-native-image-view modal which will be prompt if a user tap on any image I've added the functionality of selecting the current image on which it is tapped and than scroll left and right to the other images already present in the chat. I've not used carousel and it is not an infinite loop if user scrolls till the first image he can't scroll left more to see images.
Also I can share video, if you guys want to have a look at it.
Hey, @HasaanA16 I think it would be best if we paused working on this until we resolve my comment above.
Anyways, I'm confused about your proposal since you are describing what we already have, but mentioned multiple attachments which should not be supported.
I've added the functionality of selecting the current image on which it is tapped and than scroll left and right to the other images already present in the chat.
Hi, sorry for the delayed response.
I did not get it. I pushed my code in a separate branch so that you could test it as there were errors in chat functionality. What do you require exactly ? Did you test my code?
Putting this issue on HOLD while we sort out https://github.com/Expensify/Expensify.cash/issues/1038#issuecomment-760495360.
@marcaaron Hi folks! RNRH maintainer here. As I have some free time, I'm crafting a quote for Expansify, migrating RNRH to version 6.0.0-beta.6 with a few optimizations and I stumbled on this thread looking for issues related to my lib. If I remember well, back to alpha.10, an equivalent of passProps
was consumable via the useSharedProps
hook. As of beta.6, sharedProps
is passed to custom renderers directly, and renderersProps
are available via useRendererProps
. Hope that helps!
@jboniface, this Monthly task hasn't been acted upon in 6 weeks; closing.
If you disagree, feel encouraged to reopen it -- but pick your least important issue to close instead.
If you haven’t already, check out our contributing guidelines for onboarding!
Platform - version:
All platforms, 280
Action Performed (reproducible steps):
Expected Result: The attachments present in the chat should cycle when the user is viewing the modal and presses the left/right arrows on their keyboard
Actual Result: The attachments do not cycle
Notes/Photos/Videos:
View the job on Upwork here.