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

Fixed howto submit after deleting step image #805

Merged
merged 3 commits into from
Dec 2, 2019

Conversation

benjdelt
Copy link
Contributor

@benjdelt benjdelt commented Nov 28, 2019

Fix for #756 I found the problem. In howto.store.tsx, line 129, when an image is deleted, the object in the stepImages variable is set to null, then that array gets iterated on in uploadCollectionBatch() and the function tries to access properties on null. I added a filter to remove falsey values from the stepImages array. As I’m not very familiar with the codebase yet, I am open to suggestions as to solve this differently if there is a better way.

@cypress
Copy link

cypress bot commented Nov 28, 2019



Test summary

30 0 10 0


Run details

Project onearmy-community-platform
Status Passed
Commit cd82c36
Started Dec 1, 2019 11:31 PM
Ended Dec 1, 2019 11:38 PM
Duration 07:17 💡
OS Linux Ubuntu Linux - 14.04
Browser Electron 73

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@BenGamma
Copy link
Contributor

BenGamma commented Dec 1, 2019

Yep I like the check with the double exclamation point, it's a better approach than with the shift() method. If I understand well is to be sure that the value returned will be boolean ?

@BenGamma BenGamma closed this Dec 1, 2019
@BenGamma BenGamma reopened this Dec 1, 2019
@benjdelt
Copy link
Contributor Author

benjdelt commented Dec 1, 2019

Yep I like the check with the double exclamation point, it's a better approach than with the shift() method. If I understand well is to be sure that the value returned will be boolean ?

Yes, the double exclamation point forces the value into a boolean and the filter function removes false values from the array, preventing the uploadCollectionBatch function to call properties on them. As every remaining image data is an object inside the array, they can never be falsey and they can never be filtered out. Only the deleted images will be filtered out.

Copy link
Contributor

@BenGamma BenGamma left a comment

Choose a reason for hiding this comment

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

Alright thanks for clarity, that seems like a good option 💪

@BenGamma BenGamma merged commit 1ca50f1 into ONEARMY:master Dec 2, 2019
@benjdelt
Copy link
Contributor Author

benjdelt commented Dec 2, 2019

Alright thanks for clarity, that seems like a good option 💪

Thanks, @BenGamma !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants