-
Notifications
You must be signed in to change notification settings - Fork 2
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
Lessons 30-33 #1
Open
gjaldon
wants to merge
37
commits into
LearnPhoenix:master
Choose a base branch
from
gjaldon:lesson-30
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We listen to the presence_state and presence_diff events so we can keep track of and sync presences in the frontend. We then store these presences in our Chat component's state. That way, our component will rerender when presences' state changes. We pass these presences to Sidebar, which is a stateless functional component, and only deals with rendering of the presences.
An admin can now click on a user on the sidebar and view messages from that user. A user can send messages and the admin will receive them in real-time. Since our messages are already persisted in the DB, admin will be able to see them every time they join a chatroom. Next, we will need admin to be able to respond to users.
We handle input entered by admin and send the input to the backend on when they press 'Enter'. Since we already have the logic in place for sending this message to all members of a room, the user will receive this message once it has been saved and broadcast by our server.
The host for our JSON API and Websocket servers will be different in our production environment. This needs to be configurable. In Webpack, we can define values during build time which can be configured to be different depending on your environment. Later on, we will add a webpack config specifically for production so we can easily create a production build and deploy it.
Using presences alone to populate admin's sidebar doesn't allow us to see inactive users. To deal with this, we populate our list with users that we store in our server. Since our server passes a list of anonymous users when we connect to admin:active_users, we can use this list to fill up our sidebar with an initial list of users. To handle updating this list, we listen to the lobby_list event. Through this event, the server will pass us users that have connected to our app. Once connected, we check if that user exists in our list and add them if they are new.
The commits and what lessons they are related to:
|
samcorcos
force-pushed
the
master
branch
2 times, most recently
from
September 20, 2016 07:02
741591c
to
d974508
Compare
samcorcos
force-pushed
the
master
branch
2 times, most recently
from
September 22, 2016 03:36
ca9af74
to
7f11a9f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.