Members
selectBuddy
As the user selects a buddy to chat with from the selection list, the chat box is updated accordingly.
Methods
componentDidMount()
As soon as this component is loaded the, the selection list of buddies is filled up according to circle of currently logged in user.
componentDidUpdate()
As soon as new messages are arrived, scrollToBottom() function is called.
componentWillUnmount()
When the user leaves this component, the fetchMessages() schedule is stopped, so that it doesn't run in background while user is exploring other components.
doSend(event)
Sends the text message to the backend. Before sending, this function preprocesses the the message string by removing unncessary spaces. Also, blank messages are ignored.
Parameters:
Name | Type | Description |
---|---|---|
event |
Object | Event object |
fetchMessages()
Fetches latest messages from the backend and updates the state of the component. This function is scheduled to run at every 100ms.
render()
Renders the input form based on state of the component.
scrollToBottom()
As the user chats with their buddy, the messages are bound to cross the size of chat box element. So, for the convenience of user, this function does that automatically, so that user won't have to scroll down to see the latest messages.
textInputHandler(event)
Executes at each keystroke of user for any input text field in the component. As soon as it receives any keystroke from user, this method updates the state of the component accordingly.
Parameters:
Name | Type | Description |
---|---|---|
event |
Object | Event object |