From b833976b77194f08f13aae1b9fff481cf4d590c2 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 11 Oct 2017 09:58:20 -0400 Subject: [PATCH] Clean up ahead of PR. // FREEBIE --- .../ConversationView/ConversationViewItem.m | 4 ++-- .../ConversationView/ConversationViewLayout.h | 3 +++ .../ConversationView/ConversationViewLayout.m | 10 +++++----- Signal/src/ViewControllers/HomeViewController.m | 5 ----- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m index 0fe1ee754..9b6b365ce 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m @@ -217,6 +217,8 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - View State +// TODO: Now that we're caching the displayable text on the view items, +// I don't think we need this cache any more. - (NSCache *)displayableTextCache { static NSCache *cache = nil; @@ -285,7 +287,6 @@ NS_ASSUME_NONNULL_BEGIN TSMessage *interaction = (TSMessage *)self.interaction; if (interaction.body.length > 0) { self.messageCellType = OWSMessageCellType_TextMessage; - // TODO: This can be expensive. Should we cache it on the view item? self.textMessage = [self displayableTextForText:interaction.body interactionId:interaction.uniqueId]; return; } else { @@ -297,7 +298,6 @@ NS_ASSUME_NONNULL_BEGIN if ([attachment.contentType isEqualToString:OWSMimeTypeOversizeTextMessage]) { self.messageCellType = OWSMessageCellType_OversizeTextMessage; - // TODO: This can be expensive. Should we cache it on the view item? self.textMessage = [self displayableTextForAttachmentStream:self.attachmentStream interactionId:interaction.uniqueId]; return; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.h b/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.h index d9addf8a8..515629fac 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.h +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.h @@ -5,6 +5,7 @@ NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(NSInteger, ConversationViewLayoutAlignment) { + // We use incoming/outgoing, not left/right to support RTL. ConversationViewLayoutAlignment_Incoming, ConversationViewLayoutAlignment_Outgoing, ConversationViewLayoutAlignment_FullWidth, @@ -29,6 +30,8 @@ typedef NS_ENUM(NSInteger, ConversationViewLayoutAlignment) { #pragma mark - +// A new lean and efficient layout for conversation view designed to +// handle our edge cases (e.g. full-width unread indicators, etc.). @interface ConversationViewLayout : UICollectionViewLayout @property (nonatomic, weak) id delegate; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m b/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m index 901d8408b..0019e739a 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m @@ -12,11 +12,11 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) CGSize contentSize; @property (nonatomic, readonly) NSMutableDictionary *itemAttributesMap; -// This may be redundant with logic in UICollectionViewLayout, but -// it can't hurt and it ensures that we can safely & cheaply call -// prepareLayout from view logic to ensure that we always have a -// valid layout without incurring any of the (great) expense of -// performing an unnecessary layout pass. +// This dirty flag may be redundant with logic in UICollectionViewLayout, +// but it can't hurt and it ensures that we can safely & cheaply call +// prepareLayout from view logic to ensure that we always have a¸valid +// layout without incurring any of the (great) expense of performing an +// unnecessary layout pass. @property (nonatomic) BOOL hasLayout; @end diff --git a/Signal/src/ViewControllers/HomeViewController.m b/Signal/src/ViewControllers/HomeViewController.m index 78e4e02c4..1acd72fac 100644 --- a/Signal/src/ViewControllers/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeViewController.m @@ -270,11 +270,6 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; } [self updateBarButtonItems]; - - dispatch_async(dispatch_get_main_queue(), ^{ - TSThread *thread = [self threadForIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; - [self presentThread:thread keyboardOnViewAppearing:NO callOnViewAppearing:NO]; - }); } - (void)updateBarButtonItems