-
Notifications
You must be signed in to change notification settings - Fork 691
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
Lazily load user list in channels on init, keep autocompletion sort on server #1194
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it took me longer to figure out how this worked than it took for you to write it :-P
src/models/chan.js
Outdated
@@ -95,6 +95,7 @@ Chan.prototype.getMode = function(name) { | |||
|
|||
Chan.prototype.toJSON = function() { | |||
var clone = _.clone(this); | |||
clone.users = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a quick comment here just mentioning why we do this. I can see it would be confusing for people coming to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, still want this comment.
Don't merge it, it breaks auto completion (sorting) as users will be empty. |
76b4ea4
to
dc637a1
Compare
dc637a1
to
bd9520d
Compare
I have fixed auto completion! |
client/js/render.js
Outdated
return (oldSortOrder[a] || Number.MAX_VALUE) - (oldSortOrder[b] || Number.MAX_VALUE); | ||
}); | ||
const nicks = data.users | ||
.concat() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does nothing, unless I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make a copy of the object, because it sorts in-place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Well that's a very confusing way of doing it. I thin kthe standard way to do it is with slice(0), isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no difference. i'll add a comment here
client/js/render.js
Outdated
}); | ||
const nicks = data.users | ||
.concat() | ||
.sort((a, b) => b.lastMessage - a.lastMessage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I must have missed the point of renderChannelUsers. Is it not for the users for the sidebar? Because it looks like we are sorting based on when they last sent a message, which wouldn't make sense for the sidebar. So is this for the autocompletion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is sorting auto completion, yes.
src/models/chan.js
Outdated
@@ -95,6 +95,7 @@ Chan.prototype.getMode = function(name) { | |||
|
|||
Chan.prototype.toJSON = function() { | |||
var clone = _.clone(this); | |||
clone.users = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, still want this comment.
bd9520d
to
3beb872
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, looks good. I haven't tested it, but the code looks fine. Will test sometime (probably not today)
Fixed a case where last message time would be reset when NAMES event is received. This change should also improve GC performance as we will keep |
9be839a
to
d8f3ad4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me (squash commits?) and works great.
If you can think of a single test to add, that would be super great, but I can't, so up to you.
Should PR description say that this resolves #289?
client/js/render.js
Outdated
@@ -83,7 +83,7 @@ function buildChatMessage(data) { | |||
text.html(templates.actions[type](data.msg)); | |||
} | |||
|
|||
if ((type === "message" || type === "action") && chan.hasClass("channel")) { | |||
if ((type === "message" || type === "action" || type === "notice") && chan.hasClass("channel")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you need this addition? Sorry, not questioning, I'm just not seeing it 😅.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notices are processed in same callback on the server as normal messages and actions. So this change was needed to match ordering correctly.
@astorije Commits are better left without squashing. |
This is required to keep lastMessage correct. This will also be useful for the away tracking PR.
d8f3ad4
to
7d981d6
Compare
Lazily load user list in channels on init, keep autocompletion sort on server
Less bandwidth and processing on initial page load.