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 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];

@ -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: "<b>", with: "")
.replacingOccurrences(of: "</b>", with: "")
.replacingOccurrences(of: "<B>", with: "")
.replacingOccurrences(of: "</B>", 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
}

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

@ -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<NSString *> *)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];

@ -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];

@ -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

@ -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)

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

Loading…
Cancel
Save