-
Notifications
You must be signed in to change notification settings - Fork 703
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
Add human-readable idle time in whois info #721
Conversation
6656b9c
to
61de123
Compare
bit of a nitpick, but I think there should be an oxford comma after the minutes before the |
I thought about it, then decided to not do that. I can update if people have strong feelings about that. |
{{#if whois.idle}} | ||
<div> | ||
<span role="button" class="user {{colorClass whois.nick}}" data-name="{{whois.nick}}">{{whois.nick}}</span> | ||
has been idle for {{humanReadableRange whois.idle}}. |
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.
Tooltip with just the date.
@@ -844,7 +844,7 @@ $(function() { | |||
|
|||
socket.emit("input", { | |||
target: chat.data("id"), | |||
text: "/whois " + name | |||
text: "/whois " + name + " " + name |
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.
@DanielOaks mind saying if there could be any problems with this?
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.
Hmm I'll take a look, do some testing and let you know
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.
@DanielOaks, any luck? :)
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.
@astorije Ah, sorry. I had a squiz, it's not really defined anywhere but servers out there process it without an issue. Some like Insp also seem to require it to send all the WHOIS info. Should be fine, yeah.
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.
@astorije a comment in the code here, explaining why the name is repeated, might be helpful in the future
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.
@xPaw, @DanielOaks, if you look at the third commit of this PR, I actually moved that logic to the server through a new input file.
Reason behind that is that with the second commit alone, clicking on a nick and typing /whois nick
were giving different outputs, and it confused me for a second. Now whois nick
directly sends /whois nick nick
(just like /away
sends /away <empty reason>
) and it's nicer for the user.
I'll squash commits 2 and 3 if you're ok with that (commit 3 cancels out commit 2, but I kept it for now just in case).
@PolarizedIons, done.
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.
Mostly happy with this, but I agree about the oxford comma. It doesn't actually matter, but it'll annoy me every time I use the feature if you don't put it in :-P
1960eed
to
5c873c8
Compare
@YaManicKill, @xPaw, I ended up moving away from the "since X days, X hours, ..." format I created and used the same date-time format we use for other dates in the UI. Reason is that when we start using relative dates for the date marker with moment, we can add it here as well and move the full date in a tooltip so it says "has been idle for about 2 hours" or the like. For the oxford comma, I started to look at it then gave up as I would have had to make sure there is no comma with only 2 values. Painful. Better handled later. |
// This queries server of the other user and not of the current user, which | ||
// does not know idle time. | ||
// See http://superuser.com/a/272069/208074. | ||
network.irc.raw("WHOIS", args[0], args[0]); |
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.
Yeeah, this might have side effects. As the command is described as this: WHOIS [<server>] <nickmask>[,<nickmask>[,...]]
So if you tried to query nick on a server, your command would not work.
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.
Good call. How do you suggest I do that? Solve it on the server or just cancel and go back to client-side only?
If server-side, what about:
if (args.length === 1) {
network.irc.raw("WHOIS", args[0], args[0]);
} else {
network.irc.raw("WHOIS", args.join(" "));
}
or something like that?
/whois nick
would always be /whois nick nick
, and everything else would be forwarded as is.
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.
args.join(" ")
seems like it'd combine all args into the trailing, so would it end up sending out something like this?
WHOIS :arg1 arg2
That wouldn't go well. If that's how it'd send out with the above, you'd need to make it push all args separately instead (not sure how you'd do that in JS, but in other langs it'd look something like network.irc.raw("WHOIS", args...);
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 guess that would be network.irc.raw("WHOIS", ...args);
in JS with ES6's spread operator. Will wait for a LGTM or better suggestion from @xPaw.
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.
Scratch that, I re-assembled the whole command that gets parsed in client.js
and it works just fine (spread operator is not available in Node.js v4...).
@@ -27,6 +27,9 @@ module.exports = function(irc, network) { | |||
text: "No such nick: " + data.nick | |||
}); | |||
} else { | |||
// Absolute datetime in milliseconds since nick is idle | |||
data.idleTime = Date.now() - data.idle * 1000; |
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.
Not entirely sure if whois messages can have server-time
, but if they do, use that instead maybe?
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 don't know much about server-time
but if that's supposed to come along with data
, then I don't receive it there.
Looking at irc-framework
's handlers, I don't see such evidence. Can you confirm or help me a bit on this?
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.
Hmm maybe that's just missing in the framework. cc @prawnsalad
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 suggest going with what we have right now and improving if/when irc-framework adds this (if possible). In the meantime, this works just fine (and also I am sooo over that PR :D).
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.
Revert /whois
command.
5c873c8
to
48e5ba6
Compare
@xPaw, see my latest commit, I think that's the best compromise: WHOIS with a single argument gets repeated, everything else gets sent raw as-is. |
This queries server of the other user and not current user, which does not know idle time. See http://superuser.com/a/272069/208074. Override is done before command is being sent to the server: if a single argument is given to `/whois`, it is being repeated, otherwise the command is sent as is.
48e5ba6
to
da2e286
Compare
Add human-readable idle time in whois info
One step towards #560.
See http://superuser.com/a/272069/208074 for explanation on
/whois nick nick
instead of/whois nick
.Results
This PR used to say "since X days, X hours, X minutes and X seconds" but was moved to the format above for simplicity and consistency with other date/times in the current UI.
Helper and tests to do that have been moved to the archive PR #819.