瀏覽代碼

fix resetting of highlighted substrings if there's no more match

cyberta 5 年之前
父節點
當前提交
460da55e45
共有 1 個文件被更改,包括 6 次插入5 次删除
  1. 6 5
      deltachat-ios/Controller/NewChatViewController.swift

+ 6 - 5
deltachat-ios/Controller/NewChatViewController.swift

@@ -286,23 +286,24 @@ class NewChatViewController: UITableViewController {
         let contact = contactWithHighlight.contact
         let displayName = contact.displayName
 
-        cell.nameLabel.text = displayName
-        cell.emailLabel.text = contact.email
+        let emailLabelFontSize = cell.emailLabel.font.pointSize
+        let nameLabelFontSize = cell.nameLabel.font.pointSize
 
         cell.initialsLabel.text = Utils.getInitials(inputName: displayName)
         cell.setColor(contact.color)
 
         if let emailHighlightedIndexes = contactWithHighlight.indexesToHighlight.filter({ $0.contactDetail == .EMAIL }).first {
             // gets here when contact is a result of current search -> highlights relevant indexes
-            let emailLabelFontSize = cell.emailLabel.font.pointSize
             cell.emailLabel.attributedText = contact.email.boldAt(indexes: emailHighlightedIndexes.indexes, fontSize: emailLabelFontSize)
+        } else {
+            cell.emailLabel.attributedText = contact.email.boldAt(indexes: [], fontSize: emailLabelFontSize)
         }
 
         if let nameHighlightedIndexes = contactWithHighlight.indexesToHighlight.filter({ $0.contactDetail == .NAME }).first {
-            let nameLabelFontSize = cell.nameLabel.font.pointSize
             cell.nameLabel.attributedText = displayName.boldAt(indexes: nameHighlightedIndexes.indexes, fontSize: nameLabelFontSize)
+        } else {
+            cell.nameLabel.attributedText = displayName.boldAt(indexes: [], fontSize: nameLabelFontSize)
         }
-
     }
 
     private func searchBarIsEmpty() -> Bool {