|
|
|
@ -44,8 +44,6 @@ public class ConversationSearcher: NSObject {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public func results(searchText: String, transaction: YapDatabaseReadTransaction) -> SearchResultSet {
|
|
|
|
|
|
|
|
|
|
// TODO limit results, prioritize conversations, then contacts, then messages.
|
|
|
|
|
var conversations: [SearchResult] = []
|
|
|
|
|
var contacts: [SearchResult] = []
|
|
|
|
|
var messages: [SearchResult] = []
|
|
|
|
@ -149,50 +147,3 @@ public class ConversationSearcher: NSObject {
|
|
|
|
|
return "\(recipientId) \(contactName) \(profileName ?? "")"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//public class ConversationFullTextSearchFinder {
|
|
|
|
|
//
|
|
|
|
|
// public func enumerateObjects(searchText: String, transaction: YapDatabaseReadTransaction, block: @escaping (Any) -> Void) {
|
|
|
|
|
// guard let ext = ext(transaction: transaction) else {
|
|
|
|
|
// owsFail("ext was unexpectedly nil")
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// ext.enumerateKeysAndObjects(matching: searchText) { (_, _, object, _) in
|
|
|
|
|
// block(object)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// private func ext(transaction: YapDatabaseReadTransaction) -> YapDatabaseFullTextSearchTransaction? {
|
|
|
|
|
// return transaction.ext(ConversationFullTextSearchFinder.dbExtensionName) as? YapDatabaseFullTextSearchTransaction
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // MARK: - Extension Registration
|
|
|
|
|
//
|
|
|
|
|
// static let dbExtensionName: String = "ConversationFullTextSearchFinderExtension1"
|
|
|
|
|
//
|
|
|
|
|
// public class func asyncRegisterDatabaseExtension(storage: OWSStorage) {
|
|
|
|
|
// storage.asyncRegister(dbExtensionConfig, withName: dbExtensionName)
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // Only for testing.
|
|
|
|
|
// public class func syncRegisterDatabaseExtension(storage: OWSStorage) {
|
|
|
|
|
// storage.register(dbExtensionConfig, withName: dbExtensionName)
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// private class var dbExtensionConfig: YapDatabaseFullTextSearch {
|
|
|
|
|
// let contentColumnName = "content"
|
|
|
|
|
// let handler = YapDatabaseFullTextSearchHandler.withObjectBlock { (dict: NSMutableDictionary, _: String, _: String, object: Any) in
|
|
|
|
|
// if let groupThread = object as? TSGroupThread {
|
|
|
|
|
// dict[contentColumnName] = groupThread.groupModel.groupName
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // update search index on contact name changes?
|
|
|
|
|
// // update search index on message insertion?
|
|
|
|
|
//
|
|
|
|
|
// // TODO is it worth doing faceted search, i.e. Author / Name / Content?
|
|
|
|
|
// // seems unlikely that mobile users would use the "author: Alice" search syntax.
|
|
|
|
|
// return YapDatabaseFullTextSearch(columnNames: ["content"], handler: handler)
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|