-
Notifications
You must be signed in to change notification settings - Fork 700
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 a date separator to channels/PMs #671
Conversation
Impaloo on irc pointed out that something like "Today"/"Yesterday"/"X days ago" might be better than just displaying the date, at least for recent dates. Any thoughts on this? |
Awesome job! It seems like PolarizedIons name is slightly indented in the second photo, any idea about that? EDIT: just noticed he changed his name between PMs |
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.
Overall looks great! I made a few small comments but overall think it's a great feature.
However, currently there's no tests or way to disable it - maybe the maintainers have an option on that?
@@ -0,0 +1,5 @@ | |||
"use strict"; |
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.
Can we not use the already existing localetime somehow?
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.
You mean moving that helper into that file or using the localetime function to get the date? If the latter, that's going to be a bit more work because I'd need to localetime(date).split(",")[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.
I'm fine having these in 2 different helpers, at least for now. When we start messing up with the text itself, then we can use one within the other, but there will still be 2 helpers, so 2 files is ok IMO.
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, this is fine, imo, there is a clear difference between the 2, and we like modularity.
@@ -372,6 +408,16 @@ $(function() { | |||
.find("#chan-" + data.chan) | |||
.find(".messages"); | |||
|
|||
|
|||
// remove the date-change marker we put at the top, because it may |
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.
Please format the comments better - have the top one directly above the bottom, not indented
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.
Sorry that became a thing when switching the spaces to tabs to not get yelled at by the linter
@@ -384,6 +430,28 @@ $(function() { | |||
if (data.messages.length !== 100) { | |||
scrollable.find(".show-more").removeClass("show"); | |||
} | |||
|
|||
// Have to use data instiad of the documentFragment because it's being weird |
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.
instead*
First of, thanks a lot for this, very requested feature!! 👏 👏 I will review and test when I am on a stable network, but I wouldn't worry about "humanized" versions for dates as it comes with its set of problems: should it constantly update so that "Today" becomes "Yesterday" when a new day start without refreshing the page? What format? Custom code or package? Should a click on the date do nothing, toggle between "humazined" date and absolute date, append a hash after the URL, etc. But all that is building up on something that's already an enhancement. I say, let's have a marker that displays the native format outputted by JS (what you did here) when a new day starts (at local midnight) and improve on this later on. This will already make up for a meaty PR to review and test! |
setInterval(function () {
$('[data-relative-time]').forEach(...) // update relative times
}, 60000) something something :P |
Nice one @stepie22 Looks like it exactly doe what it's supposed to do. But as for Today, Yesterday tags, I think I'm on the same page with @astorije |
@astorije @nomadturk Thanks for all the kind words :) My first "real" PR, so it's kinda exciting |
This solution is so gross!! 😅
Well we don't need most of the niceties we have :) I am not opposed to fine-tune the solution, but long-running PRs usually get dropped. |
@@ -1142,13 +1207,34 @@ $(function() { | |||
var chan = $(this); | |||
if (chan.find(".messages .msg:not(.unread-marker)").slice(0, -100).remove().length) { | |||
chan.find(".show-more").addClass("show"); | |||
|
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 wish we got rid of this damn setInterval
, not a fan of running this 'cleanup' code a lot.
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 yea, the loop I made there felt a bit 'hacky', but it was the best solution I could come up with. Had to do this because they would not get removed with those messages. If you have suggestions about what I coded here, feel free to give.
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 spent a long time trying to think of a nicer way to do this.
You could obviously select the first child that isn't a date-change-marker, but I don't think there's a way to then delete all except 1 of the date-change-markers before it. And even if you did, jquery would still be doing the same amount of work, so ... meh.
Having said that, I think that this code could be run on initial page load and on each message, rather than on the set interval. We know that the only time this is going to be necessary is if we've had a new message received (or on initial load), don't we?
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.
@YaManicKill I agree it isn't a very good solution to the problem, but it's the best I could find, since it only happens because of the setInterval
.
Re: your last paragraph, I feel that that should be its own PR, instead of addressing it here, since I didn't add it, and xPaw has made issue #96 for 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.
Ah right, sorry I missed that the issue only happens because the setInterval exists. Alright, Ignore this then, that's a seperate PR.
@williamboman I didn't think of that case. I could add a check to see if the message is visible(which I don't feel is the "right" solution, but think is the best for now), or just not use it at all for join/parts(though I think people would disagree on this). I think I'll end up adding classes to it, to hide them if the new message would be hidden. If anyone has any thoughts on this, feel free to add |
Is anyone sure how IRCCloud handles the date separater? It makes sense to me to only show a separater if there are messages before it unless it's the most recent (meaning in the above screenshot, just 10/11/2016 would show, and a separater would appear after roots message) Also, should probably hide the date above the topic if you're just joining the channel. |
The issue @williamboman has is because of hidden joins/pars as far as I can tell. Fixing that would be a lot of work/logic, and I don't know how @astorije would feel if I loop through all the messages in a channel the visibility for a message changes to fix the position of the date. Idealy that part would be reworked so it doesnt trip this up, or the unread marker (same issue with not visible messages) |
@MaxLeiter I asked someone using IRCCloud to show what happens with the dates when they hide join/parts. This is what they sent back: |
So, seeing as that's expected behavior (compared to IRCcloud), I think this can be merged? (once commits are squashed and such) |
I'm 👎 on this one as long as it prints absolute date. (I'd much prefer relative, e.g. |
I agree with @astorije, let's get this one in (it has been up for over a month) and then someone can look at making them relative dates (either as an option or instead of this). I would much rather have this than nothing, and we are dreadful at coming to consensus. |
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 pretty good, I am really excited about this.
Just a few small changes from me, if you implement them, I'll be 100% good on this as a first step for the date marker. This looks great.
@@ -1142,13 +1207,34 @@ $(function() { | |||
var chan = $(this); | |||
if (chan.find(".messages .msg:not(.unread-marker)").slice(0, -100).remove().length) { | |||
chan.find(".show-more").addClass("show"); | |||
|
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 spent a long time trying to think of a nicer way to do this.
You could obviously select the first child that isn't a date-change-marker, but I don't think there's a way to then delete all except 1 of the date-change-markers before it. And even if you did, jquery would still be doing the same amount of work, so ... meh.
Having said that, I think that this code could be run on initial page load and on each message, rather than on the set interval. We know that the only time this is going to be necessary is if we've had a new message received (or on initial load), don't we?
@@ -0,0 +1,3 @@ | |||
<div class="date-change-marker"> |
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.
Minor nitpick, can we just call it "date-marker"? No need for the "change" (especially as the first date marker on the screen won't be about the date changing, it's about telling you the original date).
@@ -0,0 +1,5 @@ | |||
"use strict"; |
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, this is fine, imo, there is a clear difference between the 2, and we like modularity.
@williamboman I agree with @astorije and @YaManicKill, this PR has definitely dragged on long enough. I'm sure you can whip up a quick PR up to make it use relative 'dates' :) |
0262df4
to
4fe438b
Compare
4fe438b
to
08d3d8b
Compare
I've gone ahead and squashed this (with the help of YaManiac) |
08d3d8b
to
93f0f69
Compare
So, we have 2 approvals on this. @astorije You mentioned you were going to have a look at it. Do you feel you want to check it before it's merged? I'm guessing you are probably fine, but let me know if you aren't. @williamboman Are you actually 👎 on this as it is? Or are you fine with it, on the assumption that someone else will do relative dates sometime. |
I'm fine with it as it is but pls rel dates someone? |
Sorry, work has kept me busy enough that sleeping has become entirely optional now 😅 |
Add a date separator to channels/PMs
This addresses issue #89 by adding a date separator whenever the date changes between messages. It also adds it to the top of a channel (and before the 'show older messages' button) to indicate the date there.
Previews:
Date Changing:
Private message:
cc @nomadturk
This is also my first big-project PR, so I would appreciate it if you'd tell me if I did something wrong.