Bug 955658 - Match channels without insisting on the prefix and treat whitespace as AND in the awesometab, r=nhnt11.
authoraleth <aleth@instantbird.org>
Sat, 12 Oct 2013 00:34:14 +0200
changeset 17297 74d5549f26ff148beaa31d408636d634a0e013ee
parent 17296 0fda90182e8f0ddb7d352fa659aa6d78d94458da
child 17298 bed8c2e0eb6a724370caf0ee31d7abfd6c0c0270
push id1151
push userbugzilla@standard8.plus.com
push dateMon, 03 Feb 2014 22:50:32 +0000
treeherdercomm-aurora@267d8e9143d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnhnt11
bugs955658
Bug 955658 - Match channels without insisting on the prefix and treat whitespace as AND in the awesometab, r=nhnt11.
im/components/ibConvStatsService.js
--- a/im/components/ibConvStatsService.js
+++ b/im/components/ibConvStatsService.js
@@ -347,20 +347,29 @@ ConvStatsService.prototype = {
           filteredConvs.splice(
             filteredConvs.indexOf(this._contactsById.get(contact.id)), 1);
         }
       }
       let pos = this._getPositionToInsert(existingConv, filteredConvs);
       filteredConvs.splice(pos, 0, existingConv);
     }
     if (aFilterStr) {
-      aFilterStr = aFilterStr.toLowerCase();
+      let searchWords = aFilterStr.toLowerCase().split(/\s+/);
       filteredConvs = filteredConvs.filter(function(c) {
-        return c.lowerCaseName.startsWith(aFilterStr) ||
-          c.lowerCaseName.split(/\s+/).some(function(s) s.startsWith(aFilterStr));
+        let words = c.lowerCaseName.split(/\s+/);
+        return searchWords.every(function(s) {
+          return words.some(function(word) {
+            if (word.startsWith(s))
+              return true;
+            if (word.length && "#&+!@_*".indexOf(word[0]) != -1 &&
+                word.substring(1).startsWith(s))
+              return true;
+            return false;
+          });
+        });
       });
     }
     return new nsSimpleEnumerator(filteredConvs);
   },
 
   _cacheAllStats: function() {
     let encoder = new TextEncoder();
     let objToWrite = {version: gStatsCacheVersion, stats: gStatsByConvId};