-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Sort self-replies to the top of descendants #9320
Conversation
def promote_by!(arr, &condition) | ||
insert_at = arr.find_index { |item| !condition.call(item) } | ||
|
||
return arr if insert_at.nil? |
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 will always be the first status, right, since it isn't a reply?
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.
Descendants does not contain the status being replied to originally, as far as I remember. So these are all replies. However, if it's all self-replies, then there is nothing to do here, therefore return array.
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, indeed.
What happens with the following thread (where “a → b” denotes that b replied to a)? I'm afraid this gives |
ef4b101
to
82ebdd3
Compare
@ThibG That shouldn't happen, because in_reply_to_account_id carries over between self-replies. So if I reply to Bob, then reply to my reply to Bob, in_reply_to_account_id is Bob, not me. |
@Gargron ok, I didn't know that, that's super confusing. This PR should be fine in that regard, then. I'm pretty sure my inline comment still stands, though, but that's a performance issue, not a functional one. |
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 would probably add a spec to cover the case I was confused about (but seems to be handled properly), but otherwise it looks good to me.
Fix #6463