fix a minor mention issue that it won't show the name if there is no white space after a mention

This commit is contained in:
Ryan Zhao 2021-08-03 14:25:10 +10:00
parent 12a995bc91
commit 7c82ede432
2 changed files with 2 additions and 2 deletions

View File

@ -14,7 +14,7 @@ public final class MentionUtilities : NSObject {
MentionsManager.populateUserPublicKeyCacheIfNeeded(for: threadID, in: transaction)
}
var string = string
let regex = try! NSRegularExpression(pattern: "@[0-9a-fA-F]*", options: [])
let regex = try! NSRegularExpression(pattern: "@[0-9a-fA-F]{66}", options: [])
let knownPublicKeys = MentionsManager.userPublicKeyCache[threadID] ?? [] // Should always be populated at this point
var mentions: [(range: NSRange, publicKey: String)] = []
var outerMatch = regex.firstMatch(in: string, options: .withoutAnchoringBounds, range: NSRange(location: 0, length: string.utf16.count))

View File

@ -201,7 +201,7 @@ private extension String {
func replacingMentions(for threadID: String, using transaction: YapDatabaseReadWriteTransaction) -> String {
MentionsManager.populateUserPublicKeyCacheIfNeeded(for: threadID, in: transaction)
var result = self
let regex = try! NSRegularExpression(pattern: "@[0-9a-fA-F]*", options: [])
let regex = try! NSRegularExpression(pattern: "@[0-9a-fA-F]{66}", options: [])
let knownPublicKeys = MentionsManager.userPublicKeyCache[threadID] ?? []
var mentions: [(range: NSRange, publicKey: String)] = []
var m0 = regex.firstMatch(in: result, options: .withoutAnchoringBounds, range: NSRange(location: 0, length: result.utf16.count))