From 14d472781f6d243e112a0d908380f23bd71a4a74 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 21 Aug 2017 17:13:36 -0400 Subject: [PATCH] Respond to CR. // FREEBIE --- Podfile.lock | 6 +++--- Signal.xcodeproj/project.pbxproj | 4 ++-- Signal/src/Models/OWSContactOffersInteraction.h | 4 ++-- Signal/src/Models/OWSContactOffersInteraction.m | 6 +++--- .../ConversationView/MessagesViewController.m | 13 ++++++------- Signal/src/ViewControllers/DebugUI/DebugUIMisc.m | 2 +- Signal/src/util/ThreadUtil.m | 14 +++++++++++--- Signal/translations/en.lproj/Localizable.strings | 13 +++---------- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index a1be18ec1..9f3ed839a 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -43,7 +43,7 @@ PODS: - Reachability (3.2) - SAMKeychain (1.5.2) - SignalServiceKit (0.9.0): - - 25519 + - '25519' - AFNetworking - AxolotlKit - CocoaLumberjack @@ -149,7 +149,7 @@ CHECKOUT OPTIONS: :git: https://github.com/facebook/SocketRocket.git SPEC CHECKSUMS: - 25519: dc4bad7e2dbcbf1efa121068a705a44cd98c80fc + '25519': dc4bad7e2dbcbf1efa121068a705a44cd98c80fc AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 ATAppUpdater: a9f7027060959d47e58733d3b48f6b9a28cb8de1 AxolotlKit: ba0ab24b879d34559a68e1270b079cc9bd7b3417 @@ -173,4 +173,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 2f847bb25e70d1d376f38cf21ae08624fa6ed67d -COCOAPODS: 1.3.1 +COCOAPODS: 1.2.1 diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index ae06dac77..ce497d109 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -2034,7 +2034,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; 3465F381B1856CC06933B3A8 /* [CP] Copy Pods Resources */ = { @@ -2142,7 +2142,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; B4E9B04E862FB64FC9A8F79B /* [CP] Embed Pods Frameworks */ = { diff --git a/Signal/src/Models/OWSContactOffersInteraction.h b/Signal/src/Models/OWSContactOffersInteraction.h index 9a4d43ffa..8438f6470 100644 --- a/Signal/src/Models/OWSContactOffersInteraction.h +++ b/Signal/src/Models/OWSContactOffersInteraction.h @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) BOOL hasBlockOffer; @property (nonatomic, readonly) BOOL hasAddToContactsOffer; @property (nonatomic, readonly) BOOL hasAddToProfileWhitelistOffer; -@property (nonatomic, readonly) NSString *contactId; +@property (nonatomic, readonly) NSString *recipientId; - (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER; @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN hasBlockOffer:(BOOL)hasBlockOffer hasAddToContactsOffer:(BOOL)hasAddToContactsOffer hasAddToProfileWhitelistOffer:(BOOL)hasAddToProfileWhitelistOffer - contactId:(NSString *)contactId NS_DESIGNATED_INITIALIZER; + recipientId:(NSString *)recipientId NS_DESIGNATED_INITIALIZER; @end diff --git a/Signal/src/Models/OWSContactOffersInteraction.m b/Signal/src/Models/OWSContactOffersInteraction.m index 9b8fba55f..eb40eb25c 100644 --- a/Signal/src/Models/OWSContactOffersInteraction.m +++ b/Signal/src/Models/OWSContactOffersInteraction.m @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN hasBlockOffer:(BOOL)hasBlockOffer hasAddToContactsOffer:(BOOL)hasAddToContactsOffer hasAddToProfileWhitelistOffer:(BOOL)hasAddToProfileWhitelistOffer - contactId:(NSString *)contactId + recipientId:(NSString *)recipientId { self = [super initWithTimestamp:timestamp inThread:thread]; @@ -29,8 +29,8 @@ NS_ASSUME_NONNULL_BEGIN _hasBlockOffer = hasBlockOffer; _hasAddToContactsOffer = hasAddToContactsOffer; _hasAddToProfileWhitelistOffer = hasAddToProfileWhitelistOffer; - OWSAssert(contactId.length > 0); - _contactId = contactId; + OWSAssert(recipientId.length > 0); + _recipientId = recipientId; return self; } diff --git a/Signal/src/ViewControllers/ConversationView/MessagesViewController.m b/Signal/src/ViewControllers/ConversationView/MessagesViewController.m index 28ec0106d..6cd3e0481 100644 --- a/Signal/src/ViewControllers/ConversationView/MessagesViewController.m +++ b/Signal/src/ViewControllers/ConversationView/MessagesViewController.m @@ -1849,9 +1849,10 @@ typedef enum : NSUInteger { id previousMessage = [self messageAtIndexPath:[NSIndexPath indexPathForItem:indexPath.row - 1 inSection:indexPath.section]]; - // TODO: What about the contact offers? - if ([previousMessage.interaction isKindOfClass:[TSUnreadIndicatorInteraction class]]) { - // Always show timestamp between unread indicator and the following interaction + if ([previousMessage.interaction isKindOfClass:[TSUnreadIndicatorInteraction class]] || + [previousMessage.interaction isKindOfClass:[OWSContactOffersInteraction class]]) { + // Always show timestamp between unread indicator / contacts offers + // and the following interaction. return YES; } @@ -2639,7 +2640,7 @@ typedef enum : NSUInteger { } TSContactThread *contactThread = (TSContactThread *)self.thread; - NSString *displayName = [self.contactsManager displayNameForPhoneIdentifier:interaction.contactId]; + NSString *displayName = [self.contactsManager displayNameForPhoneIdentifier:interaction.recipientId]; NSString *title = [NSString stringWithFormat:NSLocalizedString(@"BLOCK_OFFER_ACTIONSHEET_TITLE_FORMAT", @"Title format for action sheet that offers to block an unknown user." @@ -2660,7 +2661,7 @@ typedef enum : NSUInteger { style:UIAlertActionStyleDestructive handler:^(UIAlertAction *_Nonnull action) { DDLogInfo(@"%@ Blocking an unknown user.", self.tag); - [self.blockingManager addBlockedPhoneNumber:interaction.contactId]; + [self.blockingManager addBlockedPhoneNumber:interaction.recipientId]; // Delete the offers. [self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { @@ -4251,8 +4252,6 @@ typedef enum : NSUInteger { TSInteraction *interaction = [self interactionAtIndexPath:indexPath]; // Show any top/bottom labels for all but the unread indicator - // - // TODO: What about the contact offers? return !([interaction isKindOfClass:[TSUnreadIndicatorInteraction class]] || [interaction isKindOfClass:[OWSContactOffersInteraction class]]); } diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIMisc.m b/Signal/src/ViewControllers/DebugUI/DebugUIMisc.m index fe6ea8065..35fe1e082 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIMisc.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIMisc.m @@ -99,7 +99,7 @@ NS_ASSUME_NONNULL_BEGIN + (void)clearHasDismissedOffers { - [TSStorageManager.sharedManager.dbReadConnection + [TSStorageManager.sharedManager.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { NSMutableArray *contactThreads = [NSMutableArray new]; [transaction diff --git a/Signal/src/util/ThreadUtil.m b/Signal/src/util/ThreadUtil.m index 700c25973..78d7e10e3 100644 --- a/Signal/src/util/ThreadUtil.m +++ b/Signal/src/util/ThreadUtil.m @@ -153,22 +153,30 @@ NS_ASSUME_NONNULL_BEGIN const int kMaxBlockOfferOutgoingMessageCount = 10; // Find any "dynamic" interactions and safety number changes. - NSMutableArray *interactionsToDelete = [NSMutableArray new]; + // + // We use different views for performance reasons. __block TSUnreadIndicatorInteraction *existingUnreadIndicator = nil; __block OWSContactOffersInteraction *existingContactOffers = nil; NSMutableArray *blockingSafetyNumberChanges = [NSMutableArray new]; NSMutableArray *nonBlockingSafetyNumberChanges = [NSMutableArray new]; - // We use different views for performance reasons. + // We want to delete legacy and duplicate interactions. + NSMutableArray *interactionsToDelete = [NSMutableArray new]; [[TSDatabaseView threadSpecialMessagesDatabaseView:transaction] enumerateRowsInGroup:thread.uniqueId usingBlock:^( NSString *collection, NSString *key, id object, id metadata, NSUInteger index, BOOL *stop) { if ([object isKindOfClass:[OWSUnknownContactBlockOfferMessage class]]) { + // Delete this legacy interactions, which has been superseded by + // the OWSContactOffersInteraction. [interactionsToDelete addObject:object]; } else if ([object isKindOfClass:[OWSAddToContactsOfferMessage class]]) { + // Delete this legacy interactions, which has been superseded by + // the OWSContactOffersInteraction. [interactionsToDelete addObject:object]; } else if ([object isKindOfClass:[OWSAddToProfileWhitelistOfferMessage class]]) { + // Delete this legacy interactions, which has been superseded by + // the OWSContactOffersInteraction. [interactionsToDelete addObject:object]; } else if ([object isKindOfClass:[TSUnreadIndicatorInteraction class]]) { OWSAssert(!existingUnreadIndicator); @@ -469,7 +477,7 @@ NS_ASSUME_NONNULL_BEGIN hasBlockOffer:shouldHaveBlockOffer hasAddToContactsOffer:shouldHaveAddToContactsOffer hasAddToProfileWhitelistOffer:shouldHaveAddToProfileWhitelistOffer - contactId:recipientId]; + recipientId:recipientId]; [offersMessage saveWithTransaction:transaction]; DDLogInfo(@"%@ Creating contact offers: %@ (%llu)", diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 80a461d91..70a7ad252 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -820,20 +820,13 @@ /* The subtitle for the messages view title indicates that the title can be tapped to access settings for this conversation. */ "MESSAGES_VIEW_TITLE_SUBTITLE" = "Tap here for settings"; -/* Indicator that separates read from unread -// messages. - Indicator that separates read from unread messages. */ +/* Indicator that separates read from unread messages. */ "MESSAGES_VIEW_UNREAD_INDICATOR" = "Unread Messages"; -/* Messages that indicates that there are more unseen messages including safety number changes -// // that be revealed by tapping the 'load earlier messages' button. Embeds {{the name of the 'load -// // earlier messages' button}}. - Messages that indicates that there are more unseen messages including safety number changes that be revealed by tapping the 'load earlier messages' button. Embeds {{the name of the 'load earlier messages' button}}. */ +/* Messages that indicates that there are more unseen messages including safety number changes that be revealed by tapping the 'load earlier messages' button. Embeds {{the name of the 'load earlier messages' button}}. */ "MESSAGES_VIEW_UNREAD_INDICATOR_HAS_MORE_UNSEEN_MESSAGES_AND_SAFETY_NUMBER_CHANGES_FORMAT" = "There are more unread messages (including safety number changes) above. Tap \"%@\" to see them."; -/* Messages that indicates that there are more unseen messages that be revealed by tapping the -// // 'load earlier messages' button. Embeds {{the name of the 'load earlier messages' button}} - Messages that indicates that there are more unseen messages that be revealed by tapping the 'load earlier messages' button. Embeds {{the name of the 'load earlier messages' button}} */ +/* Messages that indicates that there are more unseen messages that be revealed by tapping the 'load earlier messages' button. Embeds {{the name of the 'load earlier messages' button}} */ "MESSAGES_VIEW_UNREAD_INDICATOR_HAS_MORE_UNSEEN_MESSAGES_FORMAT" = "There are more unread messages above. Tap \"%@\" to see them."; /* notification title */