-
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
Fix unread marker being removed from DOM #820
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.
Just 1 small issue.
@@ -1331,7 +1331,7 @@ $(function() { | |||
} else { | |||
var current = $(this); | |||
|
|||
if (current.attr("class") === "date-marker") { | |||
if (current.hasClass("date-marker") && prev.hasClass("date-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.
If we have the unread marker at the top, and we have 2 date markers straight after, this will not delete 1 of the date markers, will it? Because it'll drop into the else and stop there?
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.
The intended behaviour is to keep the lowest date marker, does this code not accomplish 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.
So, if we have:
- unread-marker
- date-marker
- date-marker
- message
We want to end up with
- unread-marker
- date-marker
- message
Correct?
I'm pretty sure this code will not do that, because it will set the first to be unread-marker, then it will check that both 0 and 1 are date-markers, but they aren't. So it will return false. This will then stop it doing the job, I think.
Am I 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.
That's correct. And you might be right the code is flawed. Any ideas on how to improve 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.
Simplest thing I can think of is changing the first one.
Currently we do:
if (!prev) {
// Should always be a date-seperator, because it's always added
prev = $(this);
} else {
...
So, if we want to make sure that prev is always a date-marker, we can just do this:
if (!prev) {
if ($(this).hasClass("date-marker")) {
// We only want to deal with date-markers
prev = $(this);
}
} else {
...
Then you don't need to add this extra check for the date-marker on the previous one here, as we will always have a date marker on this one.
chat.find(".active .date-marker").remove(); | ||
chat | ||
.find(".active") | ||
.find(".show-more").addClass("show").end() |
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.
Dodgy indentation.
85b6afa
to
20a9a12
Compare
20a9a12
to
7709847
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.
Yep, seems a much better solution.
Do we need a second review of this one, or is it small enough to go with 1? |
@xPaw is on a roll!! 👏 |
…pear Fix unread marker being removed from DOM
Fixes #762.