Home view cell v. group blocking
This commit is contained in:
parent
2c9d905a16
commit
809b3766c1
|
@ -46,19 +46,17 @@ class ConversationSearchViewController: UITableViewController {
|
|||
case messages
|
||||
}
|
||||
|
||||
var blockedPhoneNumberSet = Set<String>()
|
||||
|
||||
private var hasThemeChanged = false
|
||||
|
||||
var blockingManager: OWSBlockingManager {
|
||||
return OWSBlockingManager.shared()
|
||||
}
|
||||
|
||||
// MARK: View Lifecycle
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// MJK TODO
|
||||
let blockingManager = OWSBlockingManager.shared()
|
||||
blockedPhoneNumberSet = Set(blockingManager.blockedPhoneNumbers())
|
||||
|
||||
tableView.rowHeight = UITableViewAutomaticDimension
|
||||
tableView.estimatedRowHeight = 60
|
||||
tableView.separatorColor = Theme.hairlineColor
|
||||
|
@ -216,7 +214,7 @@ class ConversationSearchViewController: UITableViewController {
|
|||
owsFail("searchResult was unexpectedly nil")
|
||||
return UITableViewCell()
|
||||
}
|
||||
cell.configure(withThread: searchResult.thread, contactsManager: contactsManager, blockedPhoneNumber: self.blockedPhoneNumberSet)
|
||||
cell.configure(withThread: searchResult.thread, contactsManager: contactsManager, isBlocked: isBlocked(thread: searchResult.thread))
|
||||
return cell
|
||||
case .contacts:
|
||||
guard let cell = tableView.dequeueReusableCell(withIdentifier: ContactTableViewCell.reuseIdentifier()) as? ContactTableViewCell else {
|
||||
|
@ -266,7 +264,7 @@ class ConversationSearchViewController: UITableViewController {
|
|||
|
||||
cell.configure(withThread: searchResult.thread,
|
||||
contactsManager: contactsManager,
|
||||
blockedPhoneNumber: self.blockedPhoneNumberSet,
|
||||
isBlocked: isBlocked(thread: searchResult.thread),
|
||||
overrideSnippet: overrideSnippet,
|
||||
overrideDate: overrideDate)
|
||||
|
||||
|
@ -392,6 +390,12 @@ class ConversationSearchViewController: UITableViewController {
|
|||
override func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
||||
delegate?.conversationSearchViewWillBeginDragging()
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
|
||||
private func isBlocked(thread: ThreadViewModel) -> Bool {
|
||||
return self.blockingManager.isThreadBlocked(thread.threadRecord)
|
||||
}
|
||||
}
|
||||
|
||||
class EmptySearchResultCell: UITableViewCell {
|
||||
|
|
|
@ -14,11 +14,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (void)configureWithThread:(ThreadViewModel *)thread
|
||||
contactsManager:(OWSContactsManager *)contactsManager
|
||||
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet;
|
||||
isBlocked:(BOOL)isBlocked;
|
||||
|
||||
- (void)configureWithThread:(ThreadViewModel *)thread
|
||||
contactsManager:(OWSContactsManager *)contactsManager
|
||||
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
|
||||
isBlocked:(BOOL)isBlocked
|
||||
overrideSnippet:(nullable NSAttributedString *)overrideSnippet
|
||||
overrideDate:(nullable NSDate *)overrideDate;
|
||||
|
||||
|
|
|
@ -174,25 +174,24 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (void)configureWithThread:(ThreadViewModel *)thread
|
||||
contactsManager:(OWSContactsManager *)contactsManager
|
||||
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
|
||||
isBlocked:(BOOL)isBlocked
|
||||
{
|
||||
[self configureWithThread:thread
|
||||
contactsManager:contactsManager
|
||||
blockedPhoneNumberSet:blockedPhoneNumberSet
|
||||
isBlocked:isBlocked
|
||||
overrideSnippet:nil
|
||||
overrideDate:nil];
|
||||
}
|
||||
|
||||
- (void)configureWithThread:(ThreadViewModel *)thread
|
||||
contactsManager:(OWSContactsManager *)contactsManager
|
||||
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
|
||||
isBlocked:(BOOL)isBlocked
|
||||
overrideSnippet:(nullable NSAttributedString *)overrideSnippet
|
||||
overrideDate:(nullable NSDate *)overrideDate
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
OWSAssert(thread);
|
||||
OWSAssert(contactsManager);
|
||||
OWSAssert(blockedPhoneNumberSet);
|
||||
|
||||
[OWSTableItem configureCell:self];
|
||||
|
||||
|
@ -215,8 +214,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
if (overrideSnippet) {
|
||||
self.snippetLabel.attributedText = overrideSnippet;
|
||||
} else {
|
||||
self.snippetLabel.attributedText =
|
||||
[self attributedSnippetForThread:thread blockedPhoneNumberSet:blockedPhoneNumberSet];
|
||||
self.snippetLabel.attributedText = [self attributedSnippetForThread:thread isBlocked:isBlocked];
|
||||
}
|
||||
|
||||
self.dateTimeLabel.text
|
||||
|
@ -341,30 +339,23 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
contactsManager:contactsManager];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)attributedSnippetForThread:(ThreadViewModel *)thread
|
||||
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
|
||||
- (NSAttributedString *)attributedSnippetForThread:(ThreadViewModel *)thread isBlocked:(BOOL)isBlocked
|
||||
{
|
||||
OWSAssert(thread);
|
||||
|
||||
BOOL isBlocked = NO;
|
||||
// FIXME
|
||||
if (!thread.isGroupThread) {
|
||||
NSString *contactIdentifier = thread.contactIdentifier;
|
||||
isBlocked = [blockedPhoneNumberSet containsObject:contactIdentifier];
|
||||
}
|
||||
BOOL hasUnreadMessages = thread.hasUnreadMessages;
|
||||
|
||||
NSMutableAttributedString *snippetText = [NSMutableAttributedString new];
|
||||
if (isBlocked) {
|
||||
// If thread is blocked, don't show a snippet or mute status.
|
||||
[snippetText
|
||||
appendAttributedString:[[NSAttributedString alloc]
|
||||
initWithString:NSLocalizedString(@"HOME_VIEW_BLOCKED_CONTACT_CONVERSATION",
|
||||
@"A label for conversations with blocked users.")
|
||||
attributes:@{
|
||||
NSFontAttributeName : self.snippetFont.ows_mediumWeight,
|
||||
NSForegroundColorAttributeName : [Theme primaryColor],
|
||||
}]];
|
||||
[snippetText appendAttributedString:
|
||||
[[NSAttributedString alloc]
|
||||
initWithString:NSLocalizedString(@"HOME_VIEW_BLOCKED_CONVERSATION",
|
||||
@"Table cell subtitle label for a conversation the user has blocked.")
|
||||
attributes:@{
|
||||
NSFontAttributeName : self.snippetFont.ows_mediumWeight,
|
||||
NSForegroundColorAttributeName : [Theme primaryColor],
|
||||
}]];
|
||||
} else {
|
||||
if ([thread isMuted]) {
|
||||
[snippetText appendAttributedString:[[NSAttributedString alloc]
|
||||
|
|
|
@ -840,9 +840,9 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
|
|||
OWSAssert(cell);
|
||||
|
||||
ThreadViewModel *thread = [self threadViewModelForIndexPath:indexPath];
|
||||
[cell configureWithThread:thread
|
||||
contactsManager:self.contactsManager
|
||||
blockedPhoneNumberSet:self.blockedPhoneNumberSet];
|
||||
|
||||
BOOL isBlocked = [self.blockingManager isThreadBlocked:thread.threadRecord];
|
||||
[cell configureWithThread:thread contactsManager:self.contactsManager isBlocked:isBlocked];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
|
|
@ -1020,8 +1020,8 @@
|
|||
/* Label for 'archived conversations' button. */
|
||||
"HOME_VIEW_ARCHIVED_CONVERSATIONS" = "Archived Conversations";
|
||||
|
||||
/* A label for conversations with blocked users. */
|
||||
"HOME_VIEW_BLOCKED_CONTACT_CONVERSATION" = "Blocked";
|
||||
/* Table cell subtitle label for a conversation the user has blocked. */
|
||||
"HOME_VIEW_BLOCKED_CONVERSATION" = "Blocked";
|
||||
|
||||
/* Placeholder text for search bar which filters conversations. */
|
||||
"HOME_VIEW_CONVERSATION_SEARCHBAR_PLACEHOLDER" = "Search";
|
||||
|
|
Loading…
Reference in New Issue