From ecafe546b6a196f078d74e9e4509eb8be575ab65 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 11 Jul 2018 14:24:43 -0400 Subject: [PATCH] Rework unread indicators. --- .../ConversationView/ConversationViewController.m | 5 +---- .../ConversationView/ConversationViewItem.m | 11 ----------- .../Models/TSUnreadIndicatorInteraction.m | 2 +- SignalMessaging/utils/ThreadUtil.m | 13 +++---------- .../src/Messages/Interactions/TSInteraction.h | 2 -- .../src/Messages/Interactions/TSInteraction.m | 2 -- 6 files changed, 5 insertions(+), 30 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 2783c19fd..fd1607e01 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -741,9 +741,7 @@ typedef enum : NSUInteger { { NSInteger row = 0; for (ConversationViewItem *viewItem in self.viewItems) { - OWSInteractionType interactionType - = (viewItem ? viewItem.interaction.interactionType : OWSInteractionType_Unknown); - if (interactionType == OWSInteractionType_UnreadIndicator) { + if (viewItem.unreadIndicator) { return [NSIndexPath indexPathForRow:row inSection:0]; } row++; @@ -4742,7 +4740,6 @@ typedef enum : NSUInteger { BOOL canShowDate = NO; switch (viewItem.interaction.interactionType) { case OWSInteractionType_Unknown: - case OWSInteractionType_UnreadIndicator: case OWSInteractionType_Offer: canShowDate = NO; break; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m index 7379479fe..9ec9f041f 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m @@ -261,9 +261,6 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) case OWSInteractionType_Call: measurementCell = [OWSSystemMessageCell new]; break; - case OWSInteractionType_UnreadIndicator: - OWSFail(@"%@ unexpected unread indicator.", self.logTag); - return nil; case OWSInteractionType_Offer: measurementCell = [OWSContactOffersCell new]; break; @@ -280,11 +277,6 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) { OWSAssert(previousLayoutItem); - if (self.interaction.interactionType == OWSInteractionType_UnreadIndicator - || previousLayoutItem.interaction.interactionType == OWSInteractionType_UnreadIndicator) { - return 20.f; - } - if (self.hasCellHeader) { return OWSMessageHeaderViewDateHeaderVMargin; } @@ -326,9 +318,6 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) case OWSInteractionType_Call: return [collectionView dequeueReusableCellWithReuseIdentifier:[OWSSystemMessageCell cellReuseIdentifier] forIndexPath:indexPath]; - case OWSInteractionType_UnreadIndicator: - OWSFail(@"%@ unexpected unread indicator.", self.logTag); - return nil; case OWSInteractionType_Offer: return [collectionView dequeueReusableCellWithReuseIdentifier:[OWSContactOffersCell cellReuseIdentifier] forIndexPath:indexPath]; diff --git a/SignalMessaging/Models/TSUnreadIndicatorInteraction.m b/SignalMessaging/Models/TSUnreadIndicatorInteraction.m index acde4df42..afd976ef0 100644 --- a/SignalMessaging/Models/TSUnreadIndicatorInteraction.m +++ b/SignalMessaging/Models/TSUnreadIndicatorInteraction.m @@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN - (OWSInteractionType)interactionType { - return OWSInteractionType_UnreadIndicator; + return OWSInteractionType_Unknown; } @end diff --git a/SignalMessaging/utils/ThreadUtil.m b/SignalMessaging/utils/ThreadUtil.m index f0b1ce729..3086cab47 100644 --- a/SignalMessaging/utils/ThreadUtil.m +++ b/SignalMessaging/utils/ThreadUtil.m @@ -603,17 +603,10 @@ NS_ASSUME_NONNULL_BEGIN = (missingUnseenSafetyNumberChanges.count + nonBlockingSafetyNumberChanges.count); } - // TODO: NSInteger unreadIndicatorPosition = visibleUnseenMessageCount; - // TODO: - // if (dynamicInteractions.firstUnseenInteractionTimestamp) { - // // The unread indicator is _before_ the last visible unseen message. - // NSInteger unreadIndicatorPosition = visibleUnseenMessageCount + 1; - // if (shouldHaveContactOffers) { - // unreadIndicatorPosition++; - // } - // dynamicInteractions.unreadIndicatorPosition = @(unreadIndicatorPosition); - // } + if (shouldHaveContactOffers) { + unreadIndicatorPosition++; + } dynamicInteractions.unreadIndicator = [[OWSUnreadIndicator alloc] initUnreadIndicatorWithTimestamp:interactionAfterUnreadIndicator.timestampForSorting diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.h b/SignalServiceKit/src/Messages/Interactions/TSInteraction.h index dc44f1461..a5b29b147 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.h +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.h @@ -15,8 +15,6 @@ typedef NS_ENUM(NSInteger, OWSInteractionType) { OWSInteractionType_Error, OWSInteractionType_Call, OWSInteractionType_Info, - // TODO: Obsolete, consider replacing with OWSInteractionType_Unknown. - OWSInteractionType_UnreadIndicator, OWSInteractionType_Offer, }; diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m index 0a4bb3711..ab41fd09d 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m @@ -25,8 +25,6 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) return @"OWSInteractionType_Call"; case OWSInteractionType_Info: return @"OWSInteractionType_Info"; - case OWSInteractionType_UnreadIndicator: - return @"OWSInteractionType_UnreadIndicator"; case OWSInteractionType_Offer: return @"OWSInteractionType_Offer"; }