Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Use a single function to process and render messages #596

Merged
merged 2 commits into from
Jan 24, 2016
Merged

Use a single function to process and render messages #596

merged 2 commits into from
Jan 24, 2016

Conversation

xPaw
Copy link
Contributor

@xPaw xPaw commented Jan 20, 2016

Fixes #594 and will also help #588.

This pull request explicitly renders all received messages (on page load, channel join (unlikely to have any messages?), and loading more history) through a single function which correctly processes it and applies all the magic (e.g. makes channel names clickable).

@wizardfrag
Copy link
Contributor

lgtm 👍

@xPaw xPaw mentioned this pull request Jan 20, 2016
4 tasks

for (var i = 0; i < channels.length; i++) {
renderChannelMessages(channels[i]);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also

channels.forEach(renderChannelMessages);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed, this is much nicer and functional style, good catch @williamboman!

@astorije
Copy link
Collaborator

channel join (unlikely to have any messages?)

It actually could, if later we can display a scrollback from a previous join, so good! :-)

@astorije astorije self-assigned this Jan 22, 2016
@astorije
Copy link
Collaborator

Hey @xPaw, would you mind adding some inline comments please? To be honest, it would help me with the review, and also for future ourselves :-)

@@ -182,7 +188,7 @@ $(function() {
chan.click();
});

socket.on("msg", function(data) {
function renderChatMessage(data) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

renderChatMessage builds a message and returns it, while renderChannelMessage actually renders something, i.e. builds it and shove it into the DOM.
I would call this buildChatMessage or equivalent buildMessage is probably enough, but it's up to you) to avoid the confusion.

@astorije
Copy link
Collaborator

Hey @xPaw, I left you a few comments to improve this (and one question), but overall this looks very good! 👏
Thank you so much for this contribution! Can't wait to see this merged so that #588 gets even better!

@astorije
Copy link
Collaborator

@xPaw, looks great!
Last thing though, Shout can't run on my end if I don't run grunt. I'm guessing that's because you have changed the templates, do you mind adding the changes to this PR as well so we can ship your feature after merge?

@xPaw
Copy link
Contributor Author

xPaw commented Jan 23, 2016

I didn't include compiled templates because including them in a pull request becomes very messy quickly.

@astorije
Copy link
Collaborator

So what's your solution for this PR? If we merge this as is, Shout doesn't run, and master should be deployable as is at all times. Can you just include the changes in the compiled assets that correspond to your changes in the templates please?

@xPaw
Copy link
Contributor Author

xPaw commented Jan 23, 2016

Well the thing is, if I compile it myself and commit it, every \n will be replaced by \r\n, which is not good.

@astorije
Copy link
Collaborator

I don't believe git will let you do that: https://help.github.com/articles/dealing-with-line-endings/

@astorije
Copy link
Collaborator

👍 Awesome PR! Thanks!

@astorije astorije mentioned this pull request Jan 23, 2016
erming added a commit that referenced this pull request Jan 24, 2016
Use a single function to process and render messages
@erming erming merged commit 6c843e6 into erming:master Jan 24, 2016
@xPaw xPaw deleted the history-via-msg branch January 24, 2016 15:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants