Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent 99677899b1
commit 44b23d44fd

@ -235,7 +235,7 @@ NS_ASSUME_NONNULL_BEGIN
[stackView autoPinTrailingToSuperviewMarginWithInset:self.iconHMargin]; [stackView autoPinTrailingToSuperviewMarginWithInset:self.iconHMargin];
[stackView autoVCenterInSuperview]; [stackView autoVCenterInSuperview];
// Ensure that the cell's contents never overflow the cell bounds. // 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. // of overflow, so that changes to the margins do not trip these safe guards.
[stackView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; [stackView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:0 relation:NSLayoutRelationGreaterThanOrEqual];
[stackView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; [stackView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0 relation:NSLayoutRelationGreaterThanOrEqual];

@ -170,10 +170,10 @@ class ConversationSearchViewController: UITableViewController {
} }
var overrideSnippet = NSAttributedString() var overrideSnippet = NSAttributedString()
var overrideTimestamp: NSNumber? var overrideDate: Date?
if let messageId = searchResult.messageId { if searchResult.messageId != nil {
if let messageTimestamp = searchResult.messageTimestamp { if let messageDate = searchResult.messageDate {
overrideTimestamp = NSNumber(value: messageTimestamp) overrideDate = messageDate
} else { } else {
owsFail("\(ConversationSearchViewController.logTag) message search result is missing message timestamp") 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 // a snippet for conversations that reflects the latest
// contents. // contents.
if let messageSnippet = searchResult.snippet { if let messageSnippet = searchResult.snippet {
// YDB uses bold tags to highlight matches within the snippet. overrideSnippet = NSAttributedString(string: messageSnippet)
let filteredSnippet = messageSnippet
.replacingOccurrences(of: "<b>", with: "")
.replacingOccurrences(of: "</b>", with: "")
.replacingOccurrences(of: "<B>", with: "")
.replacingOccurrences(of: "</B>", with: "")
overrideSnippet = NSAttributedString(string: filteredSnippet)
} else { } else {
owsFail("\(ConversationSearchViewController.logTag) message search result is missing message snippet") owsFail("\(ConversationSearchViewController.logTag) message search result is missing message snippet")
} }
@ -200,7 +193,7 @@ class ConversationSearchViewController: UITableViewController {
contactsManager: contactsManager, contactsManager: contactsManager,
blockedPhoneNumber: self.blockedPhoneNumberSet, blockedPhoneNumber: self.blockedPhoneNumberSet,
overrideSnippet: overrideSnippet, overrideSnippet: overrideSnippet,
overrideTimestamp: overrideTimestamp) overrideDate: overrideDate)
return cell return cell
} }

@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
contactsManager:(OWSContactsManager *)contactsManager contactsManager:(OWSContactsManager *)contactsManager
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
overrideSnippet:(nullable NSAttributedString *)overrideSnippet overrideSnippet:(nullable NSAttributedString *)overrideSnippet
overrideTimestamp:(nullable NSNumber *)overrideTimestamp; overrideDate:(nullable NSDate *)overrideDate;
@end @end

@ -93,10 +93,14 @@ NS_ASSUME_NONNULL_BEGIN
[self.payloadView autoPinLeadingToTrailingEdgeOfView:self.avatarView offset:self.avatarHSpacing]; [self.payloadView autoPinLeadingToTrailingEdgeOfView:self.avatarView offset:self.avatarHSpacing];
[self.payloadView autoVCenterInSuperview]; [self.payloadView autoVCenterInSuperview];
// Ensure that the cell's contents never overflow the cell bounds. // 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. // 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:ALEdgeTop
[self.payloadView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; 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. // We pin the payloadView traillingEdge later, as part of the "Unread Badge" logic.
self.nameLabel = [UILabel new]; self.nameLabel = [UILabel new];
@ -136,16 +140,6 @@ NS_ASSUME_NONNULL_BEGIN
[self.unreadLabel autoCenterInSuperview]; [self.unreadLabel autoCenterInSuperview];
[self.unreadLabel setContentHuggingHigh]; [self.unreadLabel setContentHuggingHigh];
[self.unreadLabel setCompressionResistanceHigh]; [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 + (NSString *)cellReuseIdentifier
@ -171,14 +165,14 @@ NS_ASSUME_NONNULL_BEGIN
contactsManager:contactsManager contactsManager:contactsManager
blockedPhoneNumberSet:blockedPhoneNumberSet blockedPhoneNumberSet:blockedPhoneNumberSet
overrideSnippet:nil overrideSnippet:nil
overrideTimestamp:nil]; overrideDate:nil];
} }
- (void)configureWithThread:(ThreadViewModel *)thread - (void)configureWithThread:(ThreadViewModel *)thread
contactsManager:(OWSContactsManager *)contactsManager contactsManager:(OWSContactsManager *)contactsManager
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
overrideSnippet:(nullable NSAttributedString *)overrideSnippet overrideSnippet:(nullable NSAttributedString *)overrideSnippet
overrideTimestamp:(nullable NSNumber *)overrideTimestamp overrideDate:(nullable NSDate *)overrideDate
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
OWSAssert(thread); OWSAssert(thread);
@ -213,9 +207,8 @@ NS_ASSUME_NONNULL_BEGIN
// override any font attributes. // override any font attributes.
self.snippetLabel.font = [self snippetFont]; self.snippetLabel.font = [self snippetFont];
self.dateTimeLabel.text = (overrideTimestamp self.dateTimeLabel.text
? [self stringForDate:[NSDate ows_dateWithMillisecondsSince1970:overrideTimestamp.unsignedLongLongValue]] = (overrideDate ? [self stringForDate:overrideDate] : [self stringForDate:thread.lastMessageDate]);
: [self stringForDate:thread.lastMessageDate]);
if (hasUnreadMessages) { if (hasUnreadMessages) {
self.dateTimeLabel.textColor = [UIColor ows_blackColor]; self.dateTimeLabel.textColor = [UIColor ows_blackColor];

@ -789,7 +789,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
[stackView autoPinEdgeToSuperviewMargin:ALEdgeLeading relation:NSLayoutRelationGreaterThanOrEqual]; [stackView autoPinEdgeToSuperviewMargin:ALEdgeLeading relation:NSLayoutRelationGreaterThanOrEqual];
[stackView autoPinEdgeToSuperviewMargin:ALEdgeTrailing relation:NSLayoutRelationGreaterThanOrEqual]; [stackView autoPinEdgeToSuperviewMargin:ALEdgeTrailing relation:NSLayoutRelationGreaterThanOrEqual];
// Ensure that the cell's contents never overflow the cell bounds. // 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. // of overflow, so that changes to the margins do not trip these safe guards.
[stackView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; [stackView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:0 relation:NSLayoutRelationGreaterThanOrEqual];
[stackView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; [stackView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0 relation:NSLayoutRelationGreaterThanOrEqual];

@ -109,7 +109,7 @@ const CGFloat kContactTableViewCellAvatarTextMargin = 12;
[_nameContainerView autoPinTrailingToSuperviewMargin]; [_nameContainerView autoPinTrailingToSuperviewMargin];
// Ensure that the cell's contents never overflow the cell bounds. // 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. // of overflow, so that changes to the margins do not trip these safe guards.
[_avatarView autoPinEdgeToSuperviewEdge:ALEdgeTop [_avatarView autoPinEdgeToSuperviewEdge:ALEdgeTop
withInset:kMinVMargin withInset:kMinVMargin

@ -9,17 +9,17 @@ public class ConversationSearchResult: Comparable {
public let thread: ThreadViewModel public let thread: ThreadViewModel
public let messageId: String? public let messageId: String?
public let messageTimestamp: UInt64? public let messageDate: Date?
public let snippet: String? public let snippet: String?
private let sortKey: UInt64 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.thread = thread
self.sortKey = sortKey self.sortKey = sortKey
self.messageId = messageId self.messageId = messageId
self.messageTimestamp = messageTimestamp self.messageDate = messageDate
self.snippet = snippet self.snippet = snippet
} }
@ -128,7 +128,7 @@ public class ConversationSearcher: NSObject {
let searchResult = ConversationSearchResult(thread: threadViewModel, let searchResult = ConversationSearchResult(thread: threadViewModel,
sortKey: sortKey, sortKey: sortKey,
messageId: message.uniqueId, messageId: message.uniqueId,
messageTimestamp: message.timestamp, messageDate: NSDate.ows_date(withMillisecondsSince1970: message.timestamp),
snippet: snippet) snippet: snippet)
messages.append(searchResult) messages.append(searchResult)

@ -50,8 +50,10 @@ public class FullTextSearchFinder: NSObject {
let maxSearchResults = 500 let maxSearchResults = 500
var searchResultCount = 0 var searchResultCount = 0
// (snippet: String, collection: String, key: String, object: Any, stop: UnsafeMutablePointer<ObjCBool>) let snippetOptions = YapDatabaseFullTextSearchSnippetOptions()
ext.enumerateKeysAndObjects(matching: prefixQuery, with: nil) { (snippet: String, _: String, _: String, object: Any, stop: UnsafeMutablePointer<ObjCBool>) in snippetOptions.startMatchText = ""
snippetOptions.endMatchText = ""
ext.enumerateKeysAndObjects(matching: prefixQuery, with: snippetOptions) { (snippet: String, _: String, _: String, object: Any, stop: UnsafeMutablePointer<ObjCBool>) in
guard searchResultCount < maxSearchResults else { guard searchResultCount < maxSearchResults else {
stop.pointee = true stop.pointee = true
return return

Loading…
Cancel
Save