diff --git a/Session/Home/HomeVC.swift b/Session/Home/HomeVC.swift index acfcba1e2..e3a6e703c 100644 --- a/Session/Home/HomeVC.swift +++ b/Session/Home/HomeVC.swift @@ -305,7 +305,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv } @objc private func handleSeedViewedNotification(_ notification: Notification) { - self.tableView.reloadSections(IndexSet(integer: 0), with: .none) // TODO: Just reload header + self.tableView.reloadSections(IndexSet(integer: 0), with: .none) // TODO: Just reload header if possible } @objc private func handleBlockedContactsUpdatedNotification(_ notification: Notification) { diff --git a/Session/Shared/BaseVC.swift b/Session/Shared/BaseVC.swift index ee1d1aaaa..1f2ad64d9 100644 --- a/Session/Shared/BaseVC.swift +++ b/Session/Shared/BaseVC.swift @@ -82,7 +82,7 @@ class BaseVC : UIViewController { headingImageView.image = UIImage(named: "SessionHeading")?.withRenderingMode(.alwaysTemplate) headingImageView.contentMode = .scaleAspectFit headingImageView.set(.width, to: 150) - headingImageView.set(.height, to: 18) + headingImageView.set(.height, to: Values.mediumFontSize) navigationItem.titleView = headingImageView } diff --git a/Session/Shared/ConversationCell.swift b/Session/Shared/ConversationCell.swift index 054585509..95ce8a92d 100644 --- a/Session/Shared/ConversationCell.swift +++ b/Session/Shared/ConversationCell.swift @@ -210,17 +210,35 @@ final class ConversationCell : UITableViewCell { } public func configure(messageDate: Date?, snippet: String?, searchText: String) { + let normalizedSearchText = searchText.lowercased() if let messageDate = messageDate, let snippet = snippet { // Message displayNameLabel.attributedText = NSMutableAttributedString(string: getDisplayName(), attributes: [.foregroundColor:Colors.text]) timestampLabel.isHidden = false timestampLabel.text = DateUtil.formatDate(forDisplay: messageDate) bottomLabelStackView.isHidden = false - snippetLabel.attributedText = getHighlightedSnippet(snippet: snippet, searchText: searchText, fontSize: Values.smallFontSize) + snippetLabel.attributedText = getHighlightedSnippet(snippet: snippet, searchText: normalizedSearchText, fontSize: Values.smallFontSize) } else { // Contact - displayNameLabel.attributedText = getHighlightedSnippet(snippet: getDisplayName(), searchText: searchText, fontSize: Values.mediumFontSize) - bottomLabelStackView.isHidden = true + displayNameLabel.attributedText = getHighlightedSnippet(snippet: getDisplayName(), searchText: normalizedSearchText, fontSize: Values.mediumFontSize) + if threadViewModel.isGroupThread, let thread = threadViewModel.threadRecord as? TSGroupThread { + bottomLabelStackView.isHidden = false + let context: Contact.Context = thread.isOpenGroup ? .openGroup : .regular + var rawSnippet: String = "" + thread.groupModel.groupMemberIds.forEach{ id in + if let displayName = Storage.shared.getContact(with: id)?.displayName(for: context) { + if !rawSnippet.isEmpty { + rawSnippet += ", \(displayName)" + } + if displayName.lowercased().contains(normalizedSearchText) { + rawSnippet = displayName + } + } + } + snippetLabel.attributedText = getHighlightedSnippet(snippet: rawSnippet, searchText: normalizedSearchText, fontSize: Values.smallFontSize) + } else { + bottomLabelStackView.isHidden = true + } timestampLabel.isHidden = true } } @@ -232,11 +250,10 @@ final class ConversationCell : UITableViewCell { let result = NSMutableAttributedString(string: snippet, attributes: [.foregroundColor:Colors.text.withAlphaComponent(Values.lowOpacity)]) let normalizedSnippet = snippet.lowercased() as NSString - let normalizedSearchText = searchText.lowercased() - guard normalizedSnippet.contains(normalizedSearchText) else { return result } + guard normalizedSnippet.contains(searchText) else { return result } - let range = normalizedSnippet.range(of: normalizedSearchText) + let range = normalizedSnippet.range(of: searchText) result.addAttribute(.foregroundColor, value: Colors.text, range: range) result.addAttribute(.font, value: UIFont.boldSystemFont(ofSize: fontSize), range: range) return result diff --git a/SessionMessagingKit/Utilities/FullTextSearchFinder.swift b/SessionMessagingKit/Utilities/FullTextSearchFinder.swift index 44913f7a9..ecc7ae5c4 100644 --- a/SessionMessagingKit/Utilities/FullTextSearchFinder.swift +++ b/SessionMessagingKit/Utilities/FullTextSearchFinder.swift @@ -97,6 +97,7 @@ public class FullTextSearchFinder: NSObject { let snippetOptions = YapDatabaseFullTextSearchSnippetOptions() snippetOptions.startMatchText = "" snippetOptions.endMatchText = "" + snippetOptions.numberOfTokens = 5 ext.enumerateKeysAndObjects(matching: query, with: snippetOptions) { (snippet: String, _: String, _: String, object: Any, stop: UnsafeMutablePointer) in guard searchResultCount < maxSearchResults else { stop.pointee = true