Bug 1312172 - change boolean operator also on filter rules that were not yet initialized in the UI. r=mkmelin a=jorgk
authoraceman <acelists@atlas.sk>
Tue, 01 Nov 2016 13:56:00 +0100
changeset 27720 77704a98cda75e7059a69663b5991bcc3d61e05b
parent 27719 e1cda4717bd8b7bc76101a28bdf03bf6fa489651
child 27721 2fd0685a35c66569cfbbd180fbf278ea924c388a
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, jorgk
bugs1312172
Bug 1312172 - change boolean operator also on filter rules that were not yet initialized in the UI. r=mkmelin a=jorgk
mailnews/base/search/content/searchTermOverlay.js
--- a/mailnews/base/search/content/searchTermOverlay.js
+++ b/mailnews/base/search/content/searchTermOverlay.js
@@ -286,17 +286,21 @@ function booleanChanged(event) {
     // when boolean changes, we have to update all the attributes on the search terms
     var newBoolValue = (event.target.getAttribute("value") == "and");
     var matchAllValue = (event.target.getAttribute("value") == "matchAll");
     if (document.getElementById("abPopup")) {
       var selectedAB = document.getElementById("abPopup").selectedItem.value;
       setSearchScope(GetScopeForDirectoryURI(selectedAB));
     }
     for (var i=0; i<gSearchTerms.length; i++) {
-        var searchTerm = gSearchTerms[i].obj;
+        let searchTerm = gSearchTerms[i].obj;
+        // If term is not yet initialized in the UI, change the original object.
+        if (!searchTerm || !gSearchTerms[i].initialized)
+            searchTerm = gSearchTerms[i].searchTerm;
+
         searchTerm.booleanAnd = newBoolValue;
         searchTerm.matchAll = matchAllValue;
     }
     var searchTerms = document.getElementById("searchTermList");
     if (searchTerms)
     {
       if (!matchAllValue && searchTerms.hidden && !gTotalSearchTerms)
         onMore(null); // fake to get empty row.
@@ -488,26 +492,26 @@ function removeSearchRow(index)
 //               via XPCOM)
 function saveSearchTerms(searchTerms, termOwner)
 {
     var matchAll = gSearchBooleanRadiogroup.value == 'matchAll';
     var i;
     for (i = 0; i < gSearchRemovedTerms.length; i++)
         searchTerms.RemoveElement(gSearchRemovedTerms[i]);
 
-    for (i = 0; i<gSearchTerms.length; i++) {
+    for (i = 0; i < gSearchTerms.length; i++) {
         try {
             gSearchTerms[i].obj.matchAll = matchAll;
             var searchTerm = gSearchTerms[i].obj.searchTerm;
-            if (searchTerm)
+            if (searchTerm) {
                 gSearchTerms[i].obj.save();
-            else if (!gSearchTerms[i].initialized)
+            } else if (!gSearchTerms[i].initialized) {
                 // the term might be an offscreen one we haven't initialized yet
                 searchTerm = gSearchTerms[i].searchTerm;
-            else {
+            } else {
                 // need to create a new searchTerm, and somehow save it to that
                 searchTerm = termOwner.createTerm();
                 gSearchTerms[i].obj.saveTo(searchTerm);
                 // this might not be the right place for the term,
                 // but we need to make the array longer anyway
                 termOwner.appendTerm(searchTerm);
             }
             searchTerms.SetElementAt(i, searchTerm);