diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.m index 1a60642fa..2e3323cec 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.m @@ -235,7 +235,7 @@ NS_ASSUME_NONNULL_BEGIN [stackView autoPinTrailingToSuperviewMarginWithInset:self.iconHMargin]; [stackView autoVCenterInSuperview]; // Ensure that the cell's contents never overflow the cell bounds. - // We pin pin to the superview _edge_ and not _margin_ for the purposes + // We pin to the superview _edge_ and not _margin_ for the purposes // of overflow, so that changes to the margins do not trip these safe guards. [stackView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; [stackView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; diff --git a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift index 9aa1a76d4..f0ba2e854 100644 --- a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift +++ b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift @@ -170,10 +170,10 @@ class ConversationSearchViewController: UITableViewController { } var overrideSnippet = NSAttributedString() - var overrideTimestamp: NSNumber? - if let messageId = searchResult.messageId { - if let messageTimestamp = searchResult.messageTimestamp { - overrideTimestamp = NSNumber(value: messageTimestamp) + var overrideDate: Date? + if searchResult.messageId != nil { + if let messageDate = searchResult.messageDate { + overrideDate = messageDate } else { owsFail("\(ConversationSearchViewController.logTag) message search result is missing message timestamp") } @@ -183,14 +183,7 @@ class ConversationSearchViewController: UITableViewController { // a snippet for conversations that reflects the latest // contents. if let messageSnippet = searchResult.snippet { - // YDB uses bold tags to highlight matches within the snippet. - let filteredSnippet = messageSnippet - .replacingOccurrences(of: "", with: "") - .replacingOccurrences(of: "", with: "") - .replacingOccurrences(of: "", with: "") - .replacingOccurrences(of: "", with: "") - - overrideSnippet = NSAttributedString(string: filteredSnippet) + overrideSnippet = NSAttributedString(string: messageSnippet) } else { owsFail("\(ConversationSearchViewController.logTag) message search result is missing message snippet") } @@ -199,8 +192,8 @@ class ConversationSearchViewController: UITableViewController { cell.configure(withThread: searchResult.thread, contactsManager: contactsManager, blockedPhoneNumber: self.blockedPhoneNumberSet, - overrideSnippet: overrideSnippet, - overrideTimestamp: overrideTimestamp) + overrideSnippet: overrideSnippet, + overrideDate: overrideDate) return cell } diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.h b/Signal/src/ViewControllers/HomeView/HomeViewCell.h index c715ba40d..c7f249317 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.h +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN contactsManager:(OWSContactsManager *)contactsManager blockedPhoneNumberSet:(NSSet *)blockedPhoneNumberSet overrideSnippet:(nullable NSAttributedString *)overrideSnippet - overrideTimestamp:(nullable NSNumber *)overrideTimestamp; + overrideDate:(nullable NSDate *)overrideDate; @end diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index 67bb8382d..bef284b6c 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -93,10 +93,14 @@ NS_ASSUME_NONNULL_BEGIN [self.payloadView autoPinLeadingToTrailingEdgeOfView:self.avatarView offset:self.avatarHSpacing]; [self.payloadView autoVCenterInSuperview]; // Ensure that the cell's contents never overflow the cell bounds. - // We pin pin to the superview _edge_ and not _margin_ for the purposes + // We pin to the superview _edge_ and not _margin_ for the purposes // of overflow, so that changes to the margins do not trip these safe guards. - [self.payloadView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; - [self.payloadView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; + [self.payloadView autoPinEdgeToSuperviewEdge:ALEdgeTop + withInset:kMinVMargin + relation:NSLayoutRelationGreaterThanOrEqual]; + [self.payloadView autoPinEdgeToSuperviewEdge:ALEdgeBottom + withInset:kMinVMargin + relation:NSLayoutRelationGreaterThanOrEqual]; // We pin the payloadView traillingEdge later, as part of the "Unread Badge" logic. self.nameLabel = [UILabel new]; @@ -136,16 +140,6 @@ NS_ASSUME_NONNULL_BEGIN [self.unreadLabel autoCenterInSuperview]; [self.unreadLabel setContentHuggingHigh]; [self.unreadLabel setCompressionResistanceHigh]; - - // Ensure that the cell's contents never overflow the cell bounds. - // We pin pin to the superview _edge_ and not _margin_ for the purposes - // of overflow, so that changes to the margins do not trip these safe guards. - [self.payloadView autoPinEdgeToSuperviewEdge:ALEdgeTop - withInset:kMinVMargin - relation:NSLayoutRelationGreaterThanOrEqual]; - [self.payloadView autoPinEdgeToSuperviewEdge:ALEdgeBottom - withInset:kMinVMargin - relation:NSLayoutRelationGreaterThanOrEqual]; } + (NSString *)cellReuseIdentifier @@ -171,14 +165,14 @@ NS_ASSUME_NONNULL_BEGIN contactsManager:contactsManager blockedPhoneNumberSet:blockedPhoneNumberSet overrideSnippet:nil - overrideTimestamp:nil]; + overrideDate:nil]; } - (void)configureWithThread:(ThreadViewModel *)thread contactsManager:(OWSContactsManager *)contactsManager blockedPhoneNumberSet:(NSSet *)blockedPhoneNumberSet overrideSnippet:(nullable NSAttributedString *)overrideSnippet - overrideTimestamp:(nullable NSNumber *)overrideTimestamp + overrideDate:(nullable NSDate *)overrideDate { OWSAssertIsOnMainThread(); OWSAssert(thread); @@ -213,9 +207,8 @@ NS_ASSUME_NONNULL_BEGIN // override any font attributes. self.snippetLabel.font = [self snippetFont]; - self.dateTimeLabel.text = (overrideTimestamp - ? [self stringForDate:[NSDate ows_dateWithMillisecondsSince1970:overrideTimestamp.unsignedLongLongValue]] - : [self stringForDate:thread.lastMessageDate]); + self.dateTimeLabel.text + = (overrideDate ? [self stringForDate:overrideDate] : [self stringForDate:thread.lastMessageDate]); if (hasUnreadMessages) { self.dateTimeLabel.textColor = [UIColor ows_blackColor]; diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index f4e7ec4aa..900a696f5 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -789,7 +789,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations [stackView autoPinEdgeToSuperviewMargin:ALEdgeLeading relation:NSLayoutRelationGreaterThanOrEqual]; [stackView autoPinEdgeToSuperviewMargin:ALEdgeTrailing relation:NSLayoutRelationGreaterThanOrEqual]; // Ensure that the cell's contents never overflow the cell bounds. - // We pin pin to the superview _edge_ and not _margin_ for the purposes + // We pin to the superview _edge_ and not _margin_ for the purposes // of overflow, so that changes to the margins do not trip these safe guards. [stackView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; [stackView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; diff --git a/SignalMessaging/Views/ContactTableViewCell.m b/SignalMessaging/Views/ContactTableViewCell.m index d5dfd2700..06abd423a 100644 --- a/SignalMessaging/Views/ContactTableViewCell.m +++ b/SignalMessaging/Views/ContactTableViewCell.m @@ -109,7 +109,7 @@ const CGFloat kContactTableViewCellAvatarTextMargin = 12; [_nameContainerView autoPinTrailingToSuperviewMargin]; // Ensure that the cell's contents never overflow the cell bounds. - // We pin pin to the superview _edge_ and not _margin_ for the purposes + // We pin to the superview _edge_ and not _margin_ for the purposes // of overflow, so that changes to the margins do not trip these safe guards. [_avatarView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:kMinVMargin diff --git a/SignalMessaging/utils/ConversationSearcher.swift b/SignalMessaging/utils/ConversationSearcher.swift index 9a4675662..ff72a4d55 100644 --- a/SignalMessaging/utils/ConversationSearcher.swift +++ b/SignalMessaging/utils/ConversationSearcher.swift @@ -9,17 +9,17 @@ public class ConversationSearchResult: Comparable { public let thread: ThreadViewModel public let messageId: String? - public let messageTimestamp: UInt64? + public let messageDate: Date? public let snippet: String? private let sortKey: UInt64 - init(thread: ThreadViewModel, sortKey: UInt64, messageId: String? = nil, messageTimestamp: UInt64? = nil, snippet: String? = nil) { + init(thread: ThreadViewModel, sortKey: UInt64, messageId: String? = nil, messageDate: Date? = nil, snippet: String? = nil) { self.thread = thread self.sortKey = sortKey self.messageId = messageId - self.messageTimestamp = messageTimestamp + self.messageDate = messageDate self.snippet = snippet } @@ -128,7 +128,7 @@ public class ConversationSearcher: NSObject { let searchResult = ConversationSearchResult(thread: threadViewModel, sortKey: sortKey, messageId: message.uniqueId, - messageTimestamp: message.timestamp, + messageDate: NSDate.ows_date(withMillisecondsSince1970: message.timestamp), snippet: snippet) messages.append(searchResult) diff --git a/SignalServiceKit/src/Storage/FullTextSearchFinder.swift b/SignalServiceKit/src/Storage/FullTextSearchFinder.swift index d08e2941c..954c4b97d 100644 --- a/SignalServiceKit/src/Storage/FullTextSearchFinder.swift +++ b/SignalServiceKit/src/Storage/FullTextSearchFinder.swift @@ -50,8 +50,10 @@ public class FullTextSearchFinder: NSObject { let maxSearchResults = 500 var searchResultCount = 0 - // (snippet: String, collection: String, key: String, object: Any, stop: UnsafeMutablePointer) - ext.enumerateKeysAndObjects(matching: prefixQuery, with: nil) { (snippet: String, _: String, _: String, object: Any, stop: UnsafeMutablePointer) in + let snippetOptions = YapDatabaseFullTextSearchSnippetOptions() + snippetOptions.startMatchText = "" + snippetOptions.endMatchText = "" + ext.enumerateKeysAndObjects(matching: prefixQuery, with: snippetOptions) { (snippet: String, _: String, _: String, object: Any, stop: UnsafeMutablePointer) in guard searchResultCount < maxSearchResults else { stop.pointee = true return