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

Sort self-replies to the top of descendants #9320

Merged
merged 1 commit into from
Nov 24, 2018
Merged

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Nov 20, 2018

Fix #6463

@Gargron Gargron added the bug Something isn't working label Nov 20, 2018
def promote_by!(arr, &condition)
insert_at = arr.find_index { |item| !condition.call(item) }

return arr if insert_at.nil?
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, indeed.

@ClearlyClaire
Copy link
Contributor

ClearlyClaire commented Nov 21, 2018

What happens with the following thread (where “a → b” denotes that b replied to a)?
alice (1) → alice (2) → bob (3) → alice (4) → alice (5)

I'm afraid this gives alice (1), alice (2), alice (5), bob (3), alice (4) which would be extremely confusing?

@Gargron Gargron changed the title Fix wrong order of statuses in threads Sort self-replies to the top of descendants Nov 23, 2018
@Gargron Gargron added api REST API, Streaming API, Web Push API and removed bug Something isn't working labels Nov 23, 2018
@Gargron Gargron force-pushed the fix-thread-ordering branch from ef4b101 to 82ebdd3 Compare November 23, 2018 21:01
@Gargron
Copy link
Member Author

Gargron commented Nov 23, 2018

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

@ClearlyClaire
Copy link
Contributor

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

Copy link
Contributor

@ClearlyClaire ClearlyClaire left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api REST API, Streaming API, Web Push API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants