diff --git a/Signal/src/UserInterface/Notifications/AppNotifications.swift b/Signal/src/UserInterface/Notifications/AppNotifications.swift index e261a2418..4c2a4ba2f 100644 --- a/Signal/src/UserInterface/Notifications/AppNotifications.swift +++ b/Signal/src/UserInterface/Notifications/AppNotifications.swift @@ -137,8 +137,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol { @objc public override init() { - let userNotificationsFeatureEnabled = true - if userNotificationsFeatureEnabled, #available(iOS 10, *) { + if #available(iOS 10, *) { self.adaptee = UserNotificationPresenterAdaptee() } else { self.adaptee = LegacyNotificationPresenterAdaptee() diff --git a/SignalServiceKit/src/Messages/Interactions/TSMessage.m b/SignalServiceKit/src/Messages/Interactions/TSMessage.m index 8ccd7d19d..ddcbca82c 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/TSMessage.m @@ -315,36 +315,30 @@ static const NSUInteger OWSMessageSchemaVersion = 4; // TODO: This method contains view-specific logic and probably belongs in NotificationsManager, not in SSK. - (NSString *)previewTextWithTransaction:(YapDatabaseReadTransaction *)transaction -{ - NSString *_Nullable attachmentDescription = nil; - if ([self hasAttachments]) { - NSString *attachmentId = self.attachmentIds[0]; - TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId transaction:transaction]; - if ([OWSMimeTypeOversizeTextMessage isEqualToString:attachment.contentType]) { - // Handle oversize text attachments. - if ([attachment isKindOfClass:[TSAttachmentStream class]]) { - TSAttachmentStream *attachmentStream = (TSAttachmentStream *)attachment; - NSData *_Nullable data = [NSData dataWithContentsOfFile:attachmentStream.originalFilePath]; - if (data) { - NSString *_Nullable text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - if (text) { - return text.filterStringForDisplay; - } +{ + NSString *_Nullable bodyDescription = nil; + if (self.body.length > 0) { + bodyDescription = self.body; + } + + if (bodyDescription == nil) { + TSAttachment *_Nullable oversizeTextAttachment = [self oversizeTextAttachmentWithTransaction:transaction]; + if ([oversizeTextAttachment isKindOfClass:[TSAttachmentStream class]]) { + TSAttachmentStream *oversizeTextAttachmentStream = (TSAttachmentStream *)oversizeTextAttachment; + NSData *_Nullable data = [NSData dataWithContentsOfFile:oversizeTextAttachmentStream.originalFilePath]; + if (data) { + NSString *_Nullable text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + if (text) { + bodyDescription = text.filterStringForDisplay; } } - - return @""; - } else if (attachment) { - attachmentDescription = attachment.description; - } else { - attachmentDescription = NSLocalizedString(@"UNKNOWN_ATTACHMENT_LABEL", - @"In Inbox view, last message label for thread with corrupted attachment."); } } - NSString *_Nullable bodyDescription = nil; - if (self.body.length > 0) { - bodyDescription = self.body; + NSString *_Nullable attachmentDescription = nil; + TSAttachment *_Nullable mediaAttachment = [self mediaAttachmentsWithTransaction:transaction].firstObject; + if (mediaAttachment != nil) { + attachmentDescription = mediaAttachment.description; } if (attachmentDescription.length > 0 && bodyDescription.length > 0) {