better condition to tryMentionUserAction

This commit is contained in:
nixzhu
2016-01-11 17:28:28 +08:00
parent 6c4fbc22cd
commit 240ae2fdbb
@@ -493,10 +493,13 @@ extension MessageToolbar: UITextViewDelegate {
if let lastPart = parts.last {
if lastPart.hasPrefix("@") {
let usernamePrefix = lastPart.substringFromIndex(lastPart.startIndex.advancedBy(1))
mentionUsernameRange = text.rangeOfString(lastPart)
tryMentionUserAction?(usernamePrefix: usernamePrefix)
return
if !usernamePrefix.isEmpty {
mentionUsernameRange = text.rangeOfString(lastPart)
tryMentionUserAction?(usernamePrefix: usernamePrefix)
return
}
}
}