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

Add human-readable idle time in whois info #721

Merged
merged 2 commits into from Dec 23, 2016
Merged

Conversation

astorije
Copy link
Member

@astorije astorije commented Oct 27, 2016

One step towards #560.

See http://superuser.com/a/272069/208074 for explanation on /whois nick nick instead of /whois nick.

Results

screen shot 2016-12-18 at 22 17 47

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.

@astorije astorije added the Type: Feature Tickets that describe a desired feature or PRs that add them to the project. label Oct 27, 2016
@MaxLeiter
Copy link
Member

bit of a nitpick, but I think there should be an oxford comma after the minutes before the and.

@astorije
Copy link
Member Author

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}}.
Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@DanielOaks, any luck? :)

Copy link
Contributor

@DanielOaks DanielOaks Dec 7, 2016

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.

Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Member

@AlMcKinlay AlMcKinlay left a 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

@astorije
Copy link
Member Author

@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.
It makes for a simpler PR and my helper is more likely to be buggy anyway.

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.

@astorije astorije added this to the 2.2.0 milestone Dec 19, 2016
// 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]);
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Contributor

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...);

Copy link
Member Author

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.

Copy link
Member Author

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;
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member Author

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).

Copy link
Member

@xPaw xPaw left a comment

Choose a reason for hiding this comment

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

Revert /whois command.

@astorije
Copy link
Member Author

@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.
@astorije astorije merged commit c0fa58a into master Dec 23, 2016
@astorije astorije deleted the astorije/whois-idle branch December 23, 2016 08:42
matburnham pushed a commit to matburnham/lounge that referenced this pull request Sep 6, 2017
Add human-readable idle time in whois info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Tickets that describe a desired feature or PRs that add them to the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants