mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
SES-2236 Fix profile self name
This commit is contained in:
parent
ebbd95dac1
commit
5ebde324c2
@ -15,6 +15,7 @@ import org.session.libsession.avatars.ProfileContactPhoto
|
|||||||
import org.session.libsession.avatars.ResourceContactPhoto
|
import org.session.libsession.avatars.ResourceContactPhoto
|
||||||
import org.session.libsession.messaging.contacts.Contact
|
import org.session.libsession.messaging.contacts.Contact
|
||||||
import org.session.libsession.utilities.Address
|
import org.session.libsession.utilities.Address
|
||||||
|
import org.session.libsession.utilities.AppTextSecurePreferences
|
||||||
import org.session.libsession.utilities.GroupUtil
|
import org.session.libsession.utilities.GroupUtil
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||||
@ -26,6 +27,8 @@ class ProfilePictureView @JvmOverloads constructor(
|
|||||||
) : RelativeLayout(context, attrs) {
|
) : RelativeLayout(context, attrs) {
|
||||||
private val binding = ViewProfilePictureBinding.inflate(LayoutInflater.from(context), this)
|
private val binding = ViewProfilePictureBinding.inflate(LayoutInflater.from(context), this)
|
||||||
private val glide: GlideRequests = GlideApp.with(this)
|
private val glide: GlideRequests = GlideApp.with(this)
|
||||||
|
private val prefs = AppTextSecurePreferences(context)
|
||||||
|
private val userPublicKey = prefs.getLocalNumber()
|
||||||
var publicKey: String? = null
|
var publicKey: String? = null
|
||||||
var displayName: String? = null
|
var displayName: String? = null
|
||||||
var additionalPublicKey: String? = null
|
var additionalPublicKey: String? = null
|
||||||
@ -51,17 +54,15 @@ class ProfilePictureView @JvmOverloads constructor(
|
|||||||
isClosedGroupRecipient: Boolean = false,
|
isClosedGroupRecipient: Boolean = false,
|
||||||
isOpenGroupInboxRecipient: Boolean = false
|
isOpenGroupInboxRecipient: Boolean = false
|
||||||
) {
|
) {
|
||||||
fun getUserDisplayName(publicKey: String): String {
|
fun getUserDisplayName(publicKey: String): String = prefs.takeIf { userPublicKey == publicKey }?.getProfileName()
|
||||||
val contact = DatabaseComponent.get(context).sessionContactDatabase().getContactWithAccountID(publicKey)
|
?: DatabaseComponent.get(context).sessionContactDatabase().getContactWithAccountID(publicKey)?.displayName(Contact.ContactContext.REGULAR)
|
||||||
return contact?.displayName(Contact.ContactContext.REGULAR) ?: publicKey
|
?: publicKey
|
||||||
}
|
|
||||||
|
|
||||||
if (isClosedGroupRecipient) {
|
if (isClosedGroupRecipient) {
|
||||||
val members = DatabaseComponent.get(context).groupDatabase()
|
val members = DatabaseComponent.get(context).groupDatabase()
|
||||||
.getGroupMemberAddresses(address.toGroupString(), true)
|
.getGroupMemberAddresses(address.toGroupString(), true)
|
||||||
.sorted()
|
.sorted()
|
||||||
.take(2)
|
.take(2)
|
||||||
.toMutableList()
|
|
||||||
if (members.size <= 1) {
|
if (members.size <= 1) {
|
||||||
publicKey = ""
|
publicKey = ""
|
||||||
displayName = ""
|
displayName = ""
|
||||||
|
Loading…
Reference in New Issue
Block a user