Merge branch 'mkirk/long-text-notification' into release/2.38.0

pull/2/head
Michael Kirk 6 years ago
commit 1ad30f4425

@ -137,8 +137,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol {
@objc @objc
public override init() { public override init() {
let userNotificationsFeatureEnabled = true if #available(iOS 10, *) {
if userNotificationsFeatureEnabled, #available(iOS 10, *) {
self.adaptee = UserNotificationPresenterAdaptee() self.adaptee = UserNotificationPresenterAdaptee()
} else { } else {
self.adaptee = LegacyNotificationPresenterAdaptee() self.adaptee = LegacyNotificationPresenterAdaptee()

@ -315,36 +315,30 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
// TODO: This method contains view-specific logic and probably belongs in NotificationsManager, not in SSK. // TODO: This method contains view-specific logic and probably belongs in NotificationsManager, not in SSK.
- (NSString *)previewTextWithTransaction:(YapDatabaseReadTransaction *)transaction - (NSString *)previewTextWithTransaction:(YapDatabaseReadTransaction *)transaction
{ {
NSString *_Nullable attachmentDescription = nil; NSString *_Nullable bodyDescription = nil;
if ([self hasAttachments]) { if (self.body.length > 0) {
NSString *attachmentId = self.attachmentIds[0]; bodyDescription = self.body;
TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId transaction:transaction]; }
if ([OWSMimeTypeOversizeTextMessage isEqualToString:attachment.contentType]) {
// Handle oversize text attachments. if (bodyDescription == nil) {
if ([attachment isKindOfClass:[TSAttachmentStream class]]) { TSAttachment *_Nullable oversizeTextAttachment = [self oversizeTextAttachmentWithTransaction:transaction];
TSAttachmentStream *attachmentStream = (TSAttachmentStream *)attachment; if ([oversizeTextAttachment isKindOfClass:[TSAttachmentStream class]]) {
NSData *_Nullable data = [NSData dataWithContentsOfFile:attachmentStream.originalFilePath]; TSAttachmentStream *oversizeTextAttachmentStream = (TSAttachmentStream *)oversizeTextAttachment;
if (data) { NSData *_Nullable data = [NSData dataWithContentsOfFile:oversizeTextAttachmentStream.originalFilePath];
NSString *_Nullable text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; if (data) {
if (text) { NSString *_Nullable text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
return text.filterStringForDisplay; 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; NSString *_Nullable attachmentDescription = nil;
if (self.body.length > 0) { TSAttachment *_Nullable mediaAttachment = [self mediaAttachmentsWithTransaction:transaction].firstObject;
bodyDescription = self.body; if (mediaAttachment != nil) {
attachmentDescription = mediaAttachment.description;
} }
if (attachmentDescription.length > 0 && bodyDescription.length > 0) { if (attachmentDescription.length > 0 && bodyDescription.length > 0) {

Loading…
Cancel
Save