Refactored Poll and ViewPollPostPage code #200
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes the errors with the ViewPollPostPage like TypeError: undefined is not an object evaluating pollData.pollUpOrDownVoted, simplifies the code by moving the Poll post (with votes) out of the ViewPollPostPage and into it's own file (which also means post-related state can be removed from the ViewPollPostPage) and the Poll now uses the usePostReducer hook.
The PollWithVotes component was rewritten to be a class component with a custom shouldComponentUpdate to prevent re-rendering when it is unnecessary.
This also adds compatibility for the new poll-related API implementations as they are moving to having Poll votes stored in a seperate collection instead of being embedded into the Poll document. Related backend pull request: SquareTable/SocialSquare-Backend#143