-
Notifications
You must be signed in to change notification settings - Fork 171
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 bug displaying user ID when quoting own message #1332
Fix bug displaying user ID when quoting own message #1332
Conversation
@@ -72,7 +72,7 @@ class QuoteView @JvmOverloads constructor(context: Context, attrs: AttributeSet? | |||
// Author | |||
val author = contactDb.getContactWithSessionID(authorPublicKey) | |||
val localNumber = TextSecurePreferences.getLocalNumber(context) | |||
val quoteIsLocalUser = localNumber != null && localNumber == author?.sessionID | |||
val quoteIsLocalUser = localNumber != null && author == null |
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 think the issue originally arose from the author (Contact
) being null, since we are no longer storing a contact for our own user anymore. Although I'm not sure the other cases where the call to get the contact with a session ID will return null either, in the case that the contact is deleted for some reason, or maybe you only receive messages which include quotes from messages that no longer exist (so wouldn't have stored a contact against the original message?)
It might be more effective to compare localNumber != null && authorPublicKey == localNumber
, although I'm not sure what would happen in the case of blinded messages in an open group server conversation. But probably a safer comparison than the case where the author is null. Thanks for tracking down and fixing this issue!
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.
Thank you for your suggestion. Sounds good, I'm going to try this later today!
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 for taking so long. I finally got to test this and it works. It seems your solution is better, so I'm going to implement this. Thanks for your suggestion
@@ -72,7 +72,7 @@ class QuoteView @JvmOverloads constructor(context: Context, attrs: AttributeSet? | |||
// Author | |||
val author = contactDb.getContactWithSessionID(authorPublicKey) | |||
val localNumber = TextSecurePreferences.getLocalNumber(context) | |||
val quoteIsLocalUser = localNumber != null && localNumber == author?.sessionID | |||
val quoteIsLocalUser = localNumber != null && localNumber != null && authorPublicKey == localNumber |
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 think we can drop one of these localNumber != null
checks, it's doing the same thing twice
Now when quoting a own message the author displayed says "You" instead of the whole user ID. This fixes #1076
Previously:
Now: