From ce0e6db40afe0ef5f554fb25bad2a86660535e8b Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Thu, 6 Feb 2020 10:44:40 +1100 Subject: [PATCH] Fix Session Public Chat profile picture --- .../Loki/Components/ConversationCell.swift | 21 ++++++++++++------- .../OWSConversationSettingsViewController.m | 12 ++--------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Signal/src/Loki/Components/ConversationCell.swift b/Signal/src/Loki/Components/ConversationCell.swift index ddca5ca01..cb9ce6629 100644 --- a/Signal/src/Loki/Components/ConversationCell.swift +++ b/Signal/src/Loki/Components/ConversationCell.swift @@ -135,16 +135,21 @@ final class ConversationCell : UITableViewCell { LokiAPI.populateUserHexEncodedPublicKeyCacheIfNeeded(for: threadViewModel.threadRecord.uniqueId!) // FIXME: This is a terrible place to do this unreadMessagesIndicatorView.alpha = threadViewModel.hasUnreadMessages ? 1 : 0.0001 // Setting the alpha to exactly 0 causes an issue on iOS 12 if threadViewModel.isGroupThread { - let users = LokiAPI.userHexEncodedPublicKeyCache[threadViewModel.threadRecord.uniqueId!] ?? [] - let randomUsers = users.sorted().prefix(2) // Sort to provide a level of stability - if !randomUsers.isEmpty { - profilePictureView.hexEncodedPublicKey = randomUsers[0] - profilePictureView.additionalHexEncodedPublicKey = randomUsers.count >= 2 ? randomUsers[1] : "" - } else { + if threadViewModel.name == "Session Public Chat" { profilePictureView.hexEncodedPublicKey = "" - profilePictureView.additionalHexEncodedPublicKey = "" + profilePictureView.isRSSFeed = true + } else { + let users = LokiAPI.userHexEncodedPublicKeyCache[threadViewModel.threadRecord.uniqueId!] ?? [] + let randomUsers = users.sorted().prefix(2) // Sort to provide a level of stability + if !randomUsers.isEmpty { + profilePictureView.hexEncodedPublicKey = randomUsers[0] + profilePictureView.additionalHexEncodedPublicKey = randomUsers.count >= 2 ? randomUsers[1] : "" + } else { + profilePictureView.hexEncodedPublicKey = "" + profilePictureView.additionalHexEncodedPublicKey = "" + } + profilePictureView.isRSSFeed = (threadViewModel.threadRecord as? TSGroupThread)?.isRSSFeed ?? false } - profilePictureView.isRSSFeed = (threadViewModel.threadRecord as? TSGroupThread)?.isRSSFeed ?? false } else { profilePictureView.hexEncodedPublicKey = threadViewModel.contactIdentifier! profilePictureView.additionalHexEncodedPublicKey = nil diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index 8f3480efb..2c53bcc5c 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -949,16 +949,8 @@ const CGFloat kIconViewLength = 24; [stackView setLayoutMarginsRelativeArrangement:YES]; if (self.isGroupThread) { - NSMutableArray *sortedUsers = @[].mutableCopy; - NSSet *users = LKAPI.userHexEncodedPublicKeyCache[self.thread.uniqueId]; - if (users != nil) { - for (NSString *user in users) { - [sortedUsers addObject:user]; - } - } - sortedUsers = [sortedUsers sortedArrayUsingSelector:@selector(compare:)].mutableCopy; - profilePictureView.hexEncodedPublicKey = (sortedUsers.count > 0) ? sortedUsers[0] : @""; - profilePictureView.isRSSFeed = ((TSGroupThread *)self.thread).isRSSFeed; + profilePictureView.hexEncodedPublicKey = @""; + profilePictureView.isRSSFeed = true; // For now just always show the Session logo } else { profilePictureView.hexEncodedPublicKey = self.thread.contactIdentifier;