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

work in progress #15

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

work in progress #15

wants to merge 3 commits into from

Conversation

lx93
Copy link
Collaborator

@lx93 lx93 commented Aug 19, 2019

Fixes #6

imported react-chat-ui (https://www.npmjs.com/package/react-chat-ui)
renamed class {Message} in to {Msg} to avoid naming conflict with react-chat-ui

Problem:
right now the chat is always one char behind while chatting with another user. I think it has something to do with react life cycle/state update but couldnt figure out how to resolve.

@imann24
Copy link
Owner

imann24 commented Aug 20, 2019

Looks like some client-side tests are failing

@imann24
Copy link
Owner

imann24 commented Aug 20, 2019

Minor bug, seems like there are empty chat bubbles before any message are sent:
image

this.handleSubmit();
}
}
// if (event.key === ' ') {
Copy link
Owner

Choose a reason for hiding this comment

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

Is the plan to re-add the commented out code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we need to talk about the userflow and UX, as mentioned below. do we want each word occupy one bubble, and as user type each word, more bubbles will pop out?

Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Owner

Choose a reason for hiding this comment

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

Planning to remove this code?

@@ -55,12 +61,17 @@ class App extends Component {
type="text"
value={this.state.text}
onKeyPress={this.onKeyPress}
onChange={e => this.setState({ text: e.target.value })}/>
onChange={e => this.setState({ text: e.target.value },()=> console.log())}/>
Copy link
Owner

Choose a reason for hiding this comment

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

Empty console log?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

lol fixed

Copy link
Owner

Choose a reason for hiding this comment

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

Perhaps some of your changes aren't committed yet?

</div>

<ChatFeed
messages={[new Message({id: 1,message: this.state.conversation.lastMessage.text,senderName:this.state.user.name}),
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, so looks like this kind of changes the spec.

I would imagine that breaks in conversation create a new chat bubble. Instead of only have a single chat bubble per user

Copy link
Owner

Choose a reason for hiding this comment

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

Also we should clarify if a chat session only allows 2 users max

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what if we only allow 2 users for now, for simplicity sake. and we can add group chat functionality in later version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, so looks like this kind of changes the spec.

I would imagine that breaks in conversation create a new chat bubble. Instead of only have a single chat bubble per user

do you mean each word would occupy one bubble, and as user type each word, more bubbles will pop out?

Copy link
Owner

Choose a reason for hiding this comment

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

Sounds good on 2 users. Spun up an extra ticket to cover error handling (e.g. a 3rd user tries to join): #17

Let's see Issue #17 is outside the scope of this PR though and tackle that later.

In terms of bubbles, my thought is: create new bubbles whenever the person talking changes. For example:

Isaiah is talking (bubble 1 - blue)
Bill starts talking (bubble 2 - white)
Isaiah resumes talking (bubble 3 - blue)
Bill resumes talking (bubble 4 - white)

What do you think?

@@ -18,5 +18,8 @@
"devDependencies": {
"concurrently": "^4.0.1",
"recursive-install": "^1.4.0"
},
"dependencies": {
"react-chat-ui": "^0.3.2"
Copy link
Owner

@imann24 imann24 Aug 20, 2019

Choose a reason for hiding this comment

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

The hierarchy of this repo is kind of difficult. So:

|-package.json : top level development dependencies

|-- src
|--- server
|---- package.json : dependencies for frontend (probably where this belongs)

|-- src
|--- server
|---- package.json : dependencies for backend/Express server

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed!

Copy link
Owner

Choose a reason for hiding this comment

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

You may need to run npm unstainll react-chat-ui at the top level directory to remove this change (or just deletethese lines from the JSON)

@imann24
Copy link
Owner

imann24 commented Aug 20, 2019

I think the issue bug you mentioned may have something to do with needing to invoke this.setState whenever a change occurs in the data model

@lx93
Copy link
Collaborator Author

lx93 commented Aug 20, 2019

okay i will try to amend the concerns raised in your comments!

@imann24
Copy link
Owner

imann24 commented Aug 20, 2019

okay i will try to amend the concerns raised in your comments!

Sounds good! I was just teasing you about the Message to Msg one. Your class name seems more JS-like anyway!

I really like the React messaging UI. Looks very clean

Copy link
Owner

@imann24 imann24 left a comment

Choose a reason for hiding this comment

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

A few more things on a second review! Always worth looking again when you've actually had some coffee 😅 . Anyways, great PR!

@@ -47,6 +51,8 @@ class App extends Component {
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
</header>


Copy link
Owner

Choose a reason for hiding this comment

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

Nice spacing for visual clarity!

})}
</div>

<ChatFeed
Copy link
Owner

Choose a reason for hiding this comment

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

Very clean integration with the React component! Finally make React work for us!

</div>

<ChatFeed
messages={[new Message({id: 1,message: this.state.conversation.lastMessage.text,senderName:this.state.user.name}),
Copy link
Owner

Choose a reason for hiding this comment

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

Oh! Now I see that we needed to rename Msg to avoid a conflict w/ the React component. Good call!

// this.handleSubmit();
// }
// }
this.handleSubmit();
Copy link
Owner

Choose a reason for hiding this comment

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

May want to re-consider this spec in future? Sending a message through the socket on every letter typed may cause some issues (too much network traffic)

Copy link
Collaborator Author

@lx93 lx93 Aug 20, 2019

Choose a reason for hiding this comment

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

okay, whats your thoughts on this? My impression was that, as was described, user can see each letters being typed/deleted in real-time. also, i found that instead of using onKeyPress props we could use onKeyDown to trigger handleSubmit() even while user pressed backspace/shift/ctrl key.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

regarding network throughput, is there anyway we could make that work? how much traffic could websocket handle?

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, I like realtime if it's possible. Would probably have to load test to know. Want to write us some automated tests? 😅

Let's keep it live for now. We can switch it back to sending every word if we run into performance issues

@imann24 imann24 self-requested a review August 20, 2019 16:00
Copy link
Owner

@imann24 imann24 left a comment

Choose a reason for hiding this comment

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

Good code cleanup! May still have a few notes to address though

@@ -18,5 +18,8 @@
"devDependencies": {
"concurrently": "^4.0.1",
"recursive-install": "^1.4.0"
},
"dependencies": {
"react-chat-ui": "^0.3.2"
Copy link
Owner

Choose a reason for hiding this comment

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

You may need to run npm unstainll react-chat-ui at the top level directory to remove this change (or just deletethese lines from the JSON)

this.handleSubmit();
}
}
// if (event.key === ' ') {
Copy link
Owner

Choose a reason for hiding this comment

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

Planning to remove this code?

}
handleSubmit = async e => {
if (e) {
e.preventDefault();
}
let newMessage = new Message(this.state.user, this.state.text)
this.setState(previousState => ({
Copy link
Owner

Choose a reason for hiding this comment

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

Believe we still need a call to update the React state

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

which state should we update in handleSubmit?

Copy link
Owner

Choose a reason for hiding this comment

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

this.state.conversation and this.state.text

@@ -55,12 +61,17 @@ class App extends Component {
type="text"
value={this.state.text}
onKeyPress={this.onKeyPress}
onChange={e => this.setState({ text: e.target.value })}/>
onChange={e => this.setState({ text: e.target.value },()=> console.log())}/>
Copy link
Owner

Choose a reason for hiding this comment

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

Perhaps some of your changes aren't committed yet?

} else {
this.messages.push(message);
}
// let newSender = message.sender;
Copy link
Owner

Choose a reason for hiding this comment

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

Commented out code

@@ -18,5 +18,8 @@
"devDependencies": {
Copy link
Owner

Choose a reason for hiding this comment

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

Having some functional issues when I test the app:

  1. Not able to send messages with this version
  2. When I start the chat there are empty chat bubbles
  3. Think it would preferable to aim for the flow that we create a new chat bubble when the other person starts speaking

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.

Add Colored Chat Bubbles
2 participants