Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attachment cycling with onyx #1210

Closed

Conversation

ThatOneAwkwardGuy
Copy link

Implemented functionality to achieve the following statement:
"The attachments present in the chat should cycle when the user is viewing the modal and presses the left/right arrows on their keyboard"

Details

Refactored code and moved Attachment modal so only one is created for ReportActionsView and one for the ReportActionCompose view. AttachmentModal now consumed visibleModal object from Onyx to know what to show and wether to be visible.

Also wrote getNextAttachment function which retrieves the next attachment using the current action and a boolean value indicating whether to move to the right or left of the current action.

Fixed Issues

Implements #1038

Tests

  1. Upload multiple attachments (Images and PDFs)

  2. Once they have been uploaded, use the left and right arrow keys to move between all of them.

  3. Go to the last attachment and confirm that moving to the right of the last attachment takes you to the first attachment in a cyclical manner.

  4. Test that uploading attachments still work (Images, PDFs .etc)

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Screenshot 2020-12-31 at 19 33 10

Screenshot 2020-12-31 at 19 33 27

Mobile Web

no changes

Desktop

no changes

iOS

no changes

Android

no changes

@ThatOneAwkwardGuy ThatOneAwkwardGuy requested a review from a team as a code owner January 11, 2021 22:15
@botify botify requested review from marcaaron and removed request for a team January 11, 2021 22:15
@github-actions
Copy link
Contributor

github-actions bot commented Jan 11, 2021

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving in a better direction thanks! There are some problems still. If we can succeed in parsing the html instead of using the RenderHTML component we should be able to improve this.

src/pages/home/report/ReportActionsView.js Outdated Show resolved Hide resolved
src/pages/home/report/ReportActionsView.js Show resolved Hide resolved
@@ -209,7 +210,7 @@ class ReportActionCompose extends React.Component {

</>
)}
</AttachmentModal>
</ComposeAttachmentModal>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about why we are making this more specific. Could we just leave this as an AttachmentModal?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here:
#1149 (review)

tgolen suggests having separate components to keep the code clean, therefore that's why I've changed the component to its own separate ComposeAttachmentModal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgolen That seems ok to me, but the consequence is that we have shared logic being duplicated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point I would say the only thing they share is that they instantiate a modal, their purposes are quite different now and will likely get more different in the future if you decide to add upload progress .etc to the compose modal.

I believe writing a singular modal to fulfil both use cases would be more confusing.

src/pages/home/report/ReportActionCompose.js Outdated Show resolved Hide resolved
sourceURL, isAttachment, isModalOpen, file,
});
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really following why we are storing the entire state of the AttachmentModal in Onyx. We should only need to store the information we need. Which I think is just something like the activeAttachmentSourceUrl.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also file can be an instance of File which I think might not work well with storage.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this only occur when the file is uploaded, therefore would only be shown in the ComposeAttachmentModal component?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we're storing the state like this because the AttachmentModal's isModalOpen property needs to be controlled from a centralised position.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so we need the sourceURL, isAttachment, and isModalOpen? Do we need file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no clue what the initial purpose of what the file attribute was in the codebase, I assume it was to show the file name for PDFs or something. But I simply kept it because I didn't think it was my place to be deleting functionality

src/components/AttachmentModal.js Outdated Show resolved Hide resolved
src/components/AttachmentModal.js Outdated Show resolved Hide resolved
src/components/AttachmentModal.js Outdated Show resolved Hide resolved
src/components/AttachmentModal.js Show resolved Hide resolved
src/components/AttachmentModal.js Outdated Show resolved Hide resolved
@marcaaron
Copy link
Contributor

also adding @tgolen

@marcaaron marcaaron requested a review from tgolen January 12, 2021 01:28
- Changed filter to use underscore
- Fixed modal listener logic where listener would stop workin after first trigger.
src/ONYXKEYS.js Show resolved Hide resolved
src/components/AttachmentModal.js Show resolved Hide resolved
src/components/AttachmentModal.js Outdated Show resolved Hide resolved
src/components/AttachmentModal.js Outdated Show resolved Hide resolved
src/components/AttachmentModal.js Outdated Show resolved Hide resolved
src/components/AttachmentModal.js Outdated Show resolved Hide resolved
src/components/AttachmentModal.js Outdated Show resolved Hide resolved
src/components/AttachmentModal.js Outdated Show resolved Hide resolved
src/components/AttachmentModal.js Outdated Show resolved Hide resolved
src/libs/actions/Report.js Outdated Show resolved Hide resolved
changes getNextAttachment argument from toRight to direction.

Removed object destructuring for readability.
- KeyboardShortcut usages instead of document.

- AttachmentModal only now receives attachments

- Removed reportID.file.name from JSDoc definition
@chiragsalian
Copy link
Contributor

Closing PR. Marc and i discussed about this issue for a while and we feel like we should close this PR for now. We'll be splitting the original GH issue into multiple smaller issues to discuss and improve renderHTML and cycling attachments and once we've settled with a technical plan we'll be posting those in upwork.

Thank you for your time and work. Closing PR now.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants