diff --git a/Signal/src/Loki/Components/ConversationCell.swift b/Signal/src/Loki/Components/ConversationCell.swift index ad8faf2a3..9b716bf75 100644 --- a/Signal/src/Loki/Components/ConversationCell.swift +++ b/Signal/src/Loki/Components/ConversationCell.swift @@ -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 { diff --git a/Signal/src/Loki/Components/ConversationTitleView.swift b/Signal/src/Loki/Components/ConversationTitleView.swift index c811495f1..f6c74d426 100644 --- a/Signal/src/Loki/Components/ConversationTitleView.swift +++ b/Signal/src/Loki/Components/ConversationTitleView.swift @@ -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) { diff --git a/SignalMessaging/Loki/Redesign/Components/ProfilePictureView.swift b/SignalMessaging/Loki/Redesign/Components/ProfilePictureView.swift index 305ab0d2f..1192e05fb 100644 --- a/SignalMessaging/Loki/Redesign/Components/ProfilePictureView.swift +++ b/SignalMessaging/Loki/Redesign/Components/ProfilePictureView.swift @@ -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