From 10ca369da8aef09cfbd4e1c3c488fe6bfa4de33c Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 22 Feb 2018 16:12:39 -0500 Subject: [PATCH] Respond to CR. --- .../src/Messages/Interactions/TSMessage.m | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/SignalServiceKit/src/Messages/Interactions/TSMessage.m b/SignalServiceKit/src/Messages/Interactions/TSMessage.m index 8c91b1682..8b8f425ab 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSMessage.m +++ b/SignalServiceKit/src/Messages/Interactions/TSMessage.m @@ -282,22 +282,11 @@ static const NSUInteger OWSMessageSchemaVersion = 4; // TODO deprecate this and implement something like previewTextWithTransaction: for all TSInteractions - (NSString *)description { - if (self.body.length > 0) { - // Use the message text/caption, if any. - return self.body; - } else if ([self hasAttachments]) { - NSString *attachmentId = self.attachmentIds[0]; - TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId]; - if (attachment) { - return attachment.description; - } else { - return NSLocalizedString(@"UNKNOWN_ATTACHMENT_LABEL", @"In Inbox view, last message label for thread with corrupted attachment."); - } - } else { - OWSFail(@"%@ message has neither body nor attachment.", self.logTag); - // TODO: We should do better here. - return @""; - } + __block NSString *result; + [self.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { + result = [self previewTextWithTransaction:transaction]; + }]; + return result; } - (void)removeWithTransaction:(YapDatabaseReadWriteTransaction *)transaction