This repository has been archived by the owner on May 7, 2021. It is now read-only.
Individual Community Group Pages to View and Join Communities #5
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.
New Features
Individual communities can now be viewed through their own page. This page grabs the data for the community, relative to the logged in user in order to know their access to the community. This determines if they joined it or not, and if they can or not.
All the posts that have been curated/added to the community are shown, with some stats such as Likes, Views and Rating (not yet developed). YOu also know who submitted it to the group, and when.
Below the
Post
section is theMembers
section. You can see the total number of members in the header, followed by the users in the group. theRole
they have, and the date theyJoined
the group.Other Changes/Improvements
Previously, the
Join
requests where implemented on the main Communities page. But when I started to add the option in two places, theNewly Created
in addition to where it already was inRecently Active
, I had problems updating the status of the join request for one place only.As such, I decided to move the
Join
requesting to the individual community pages that I was making. It's less quick toJoin
a group, since you now have to load the community page itself rather than click onJoin
from the Communities listing page. It just made things simpler for me. Maybe I'll bring it back to the COmmunities page in the future as well.Bug and Other Fixes
This was an annoying thing that took me a while to figure out how to correct properly. I thought I would have it one day, then I would do some more coding and do certain things, like refreshing and clicking, and notice the bug was happening in another case.
With Redux, I'm loading
props
from theconnect()
method to mapStateToProps. The user authentication data is then sent to the component. But, Redux is slow. It's not like passing theprops
in from the parent component where they are available immediately in `componentDidMount.So I was ending up with empty user names and
isAuth
values defaulting to false since theprops
weren't received yet. I needed to check the user logged in withisAuth
, and a user not logged in with(!isAuth && user === 'x')
in order to get data called, along with a check incomponentDidUpdate
for when the previous user props changed to actually be the logged in user for database fetching of user related data.But when doing a page refresh, then logging out immediately, none of the components were updating for the
componentDidUpdate
to check and fetch data. Thecsrf
token was still in the Redux store, so I grabbed that as a way to check if someone just logged out and needs to get the data fetchced for them(csrf && !isAuth)
One thing I hadn't thought to check for earlier was the non-existent communities being searched for, like say if you manually typed it in, or had the page for it open in one tab, and then deleted it in another, and refreshed the page int he first. This was crashing the app because I didn't perform a check for the empty object.
To fix this, I checked the returned data to make sure the object was there by looking for it any properties having a length. If there is no length, that means there is nothing in the object, i.e. a community group that doesn't exist.
One more thing that wasn't working was the updating of the
Users
andJoin Requests
count. It's not a bug, but something that needed to be fixed.This was done with a call to increment the user count on the previous
onUserUpdate
function, and create a newonJoinRequestUpdate
function to handle reducing theJoin Requests
count by 1