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

Fix bug displaying user ID when quoting own message #1332

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

aaronkerckhoff
Copy link

@aaronkerckhoff aaronkerckhoff commented Sep 29, 2023

Now when quoting a own message the author displayed says "You" instead of the whole user ID. This fixes #1076

Previously:
Screenshot_1696028963

Now:
Screenshot_1696030466

@aaronkerckhoff aaronkerckhoff changed the base branch from master to dev September 29, 2023 23:45
@@ -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
Copy link

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!

Copy link
Author

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!

Copy link
Author

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants