-
-
Notifications
You must be signed in to change notification settings - Fork 79
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: Fix info-message orderings of verified 1:1 chats #4545
Conversation
e1c705e
to
76565e6
Compare
Python lint is already fixed on |
76565e6
to
17a3791
Compare
@@ -758,7 +758,8 @@ async fn add_parts( | |||
// message is `MessageState::InNoticed`, which means that all following | |||
// messages are sorted under it. | |||
let sort_timestamp = | |||
calc_sort_timestamp(context, sent_timestamp, chat_id, true).await?; | |||
calc_sort_timestamp(context, sent_timestamp, chat_id, true, incoming) |
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.
incoming == true
here, btw. Also i'd suggest to comment passed bool values or use enums instead, bool flags are not well-read
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.
incoming == true
here, btw
Is this just something you noticed, or you suggest replacing it with true
?
Also i'd suggest to comment passed bool values or use enums instead, bool flags are not well-read
For me, it'd be as quick to jump to the method definition and seeing what the parameter does as finding the comment that belongs to it and reading it. An enum would be nicer to read, but seemed overkill for me for a function that's used just two times.
That being said, it's not important to me to keep it as-is, so I can also change 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.
I'd suggest to replace it with smth like /* incoming = */ true
, otherwise it can be read by mistake as a common code for incoming and outgoing messages. The same for always_sort_to_bottom
, no long comments are needed. I wonder why Rust has named struct members initialisation, but no named function args.
Anyway it's minor, so up to you
Correctly handle messages with old timestamps for verified chats:
This PR fixes this:
Even seen messages can't be sorted into already-noticed messages anymore. This also changes DC's behavior in the absence of verified 1:1 chats. Before this PR, messages that are marked as seen when they are downloaded will always be sorted by their timestamp, even if it's very old.
protection-changed info messages are always sorted to the bottom.
Edit:
There is an exception to rule 1: Outgoing messages are still allowed to be sorted purely by their timestamp, and don't influence old messages. This is to the problem described at [*].
Together, these rules also make sure that the protection-changed info message is always right above the message causing the change.
[*] If we receive messages from two different folders, e.g.
Sent
andInbox
, then this will lead to wrong message ordering in many cases. I need to think about this more, or maybe someone else has an idea. One alternative that came to my mind is:However, after a talk with @link2xt we instead decided to add rule 3. (see above) because it seemed a little bit easier.