Show current user in compound profile picture if needed
This commit is contained in:
parent
07ee27f875
commit
b2c26a8f95
|
@ -145,33 +145,7 @@ final class ConversationCell : UITableViewCell {
|
|||
accentView.backgroundColor = Colors.accent
|
||||
accentView.alpha = threadViewModel.hasUnreadMessages ? 1 : 0.0001 // Setting the alpha to exactly 0 causes an issue on iOS 12
|
||||
}
|
||||
profilePictureView.openGroupProfilePicture = nil
|
||||
if threadViewModel.isGroupThread {
|
||||
if threadViewModel.name == "Loki Public Chat"
|
||||
|| threadViewModel.name == "Session Public Chat" { // Override the profile picture for the Loki Public Chat and the Session Public Chat
|
||||
profilePictureView.hexEncodedPublicKey = ""
|
||||
profilePictureView.isRSSFeed = true
|
||||
} else if let openGroupProfilePicture = (threadViewModel.threadRecord as! TSGroupThread).groupModel.groupImage { // An open group with a profile picture
|
||||
profilePictureView.openGroupProfilePicture = openGroupProfilePicture
|
||||
profilePictureView.isRSSFeed = false
|
||||
} else if (threadViewModel.threadRecord as! TSGroupThread).groupModel.groupType == .openGroup
|
||||
|| (threadViewModel.threadRecord as! TSGroupThread).groupModel.groupType == .rssFeed { // An open group without a profile picture or an RSS feed
|
||||
profilePictureView.hexEncodedPublicKey = ""
|
||||
profilePictureView.isRSSFeed = true
|
||||
} else { // A closed group
|
||||
var users = MentionsManager.userPublicKeyCache[threadViewModel.threadRecord.uniqueId!] ?? []
|
||||
users.remove(getUserHexEncodedPublicKey())
|
||||
let randomUsers = users.sorted().prefix(2) // Sort to provide a level of stability
|
||||
profilePictureView.hexEncodedPublicKey = randomUsers.count >= 1 ? randomUsers[0] : ""
|
||||
profilePictureView.additionalHexEncodedPublicKey = randomUsers.count >= 2 ? randomUsers[1] : ""
|
||||
profilePictureView.isRSSFeed = false
|
||||
}
|
||||
} else { // A one-on-one chat
|
||||
profilePictureView.hexEncodedPublicKey = threadViewModel.contactIdentifier!
|
||||
profilePictureView.additionalHexEncodedPublicKey = nil
|
||||
profilePictureView.isRSSFeed = false
|
||||
}
|
||||
profilePictureView.update()
|
||||
profilePictureView.update(for: threadViewModel.threadRecord)
|
||||
displayNameLabel.text = getDisplayName()
|
||||
timestampLabel.text = DateUtil.formatDateShort(threadViewModel.lastMessageDate)
|
||||
if SSKEnvironment.shared.typingIndicators.typingRecipientId(forThread: self.threadViewModel.threadRecord) != nil {
|
||||
|
|
|
@ -102,30 +102,7 @@ final class ConversationTitleView : UIView {
|
|||
}
|
||||
|
||||
private func updateProfilePicture() {
|
||||
if let thread = thread as? TSGroupThread {
|
||||
if thread.name() == "Loki Public Chat" || thread.name() == "Session Public Chat" { // Override the profile picture for the Loki Public Chat and the Session Public Chat
|
||||
profilePictureView.hexEncodedPublicKey = ""
|
||||
profilePictureView.isRSSFeed = true
|
||||
} else if let openGroupProfilePicture = thread.groupModel.groupImage { // An open group with a profile picture
|
||||
profilePictureView.openGroupProfilePicture = openGroupProfilePicture
|
||||
profilePictureView.isRSSFeed = false
|
||||
} else if thread.groupModel.groupType == .openGroup || thread.groupModel.groupType == .rssFeed { // An open group without a profile picture or an RSS feed
|
||||
profilePictureView.hexEncodedPublicKey = ""
|
||||
profilePictureView.isRSSFeed = true
|
||||
} else { // A closed group
|
||||
var users = MentionsManager.userPublicKeyCache[thread.uniqueId!] ?? []
|
||||
users.remove(getUserHexEncodedPublicKey())
|
||||
let randomUsers = users.sorted().prefix(2) // Sort to provide a level of stability
|
||||
profilePictureView.hexEncodedPublicKey = randomUsers.count >= 1 ? randomUsers[0] : ""
|
||||
profilePictureView.additionalHexEncodedPublicKey = randomUsers.count >= 2 ? randomUsers[1] : ""
|
||||
profilePictureView.isRSSFeed = false
|
||||
}
|
||||
} else { // A one-on-one chat
|
||||
profilePictureView.hexEncodedPublicKey = thread.contactIdentifier()!
|
||||
profilePictureView.additionalHexEncodedPublicKey = nil
|
||||
profilePictureView.isRSSFeed = false
|
||||
}
|
||||
profilePictureView.update()
|
||||
profilePictureView.update(for: thread)
|
||||
}
|
||||
|
||||
@objc private func handleProfileChangedNotification(_ notification: Notification) {
|
||||
|
|
|
@ -63,7 +63,10 @@ public final class ProfilePictureView : UIView {
|
|||
} else { // A closed group
|
||||
var users = MentionsManager.userPublicKeyCache[thread.uniqueId!] ?? []
|
||||
users.remove(getUserHexEncodedPublicKey())
|
||||
let randomUsers = users.sorted().prefix(2) // Sort to provide a level of stability
|
||||
var randomUsers = users.sorted() // Sort to provide a level of stability
|
||||
if users.count == 1 {
|
||||
randomUsers.insert(getUserHexEncodedPublicKey(), at: 0) // Ensure the current user is at the back visually
|
||||
}
|
||||
hexEncodedPublicKey = randomUsers.count >= 1 ? randomUsers[0] : ""
|
||||
additionalHexEncodedPublicKey = randomUsers.count >= 2 ? randomUsers[1] : ""
|
||||
isRSSFeed = false
|
||||
|
|
Loading…
Reference in New Issue