From 2ea55829be0467c1389dd98ac41b8724949b0081 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 09 Mar 2015 14:42:11 -0400
Subject: [PATCH] (Properly) reset search filter on reset-search action

---
 program/js/app.js |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index b8e6e77..8853335 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -774,7 +774,7 @@
 
       case 'list':
         if (props && props != '') {
-          this.reset_qsearch();
+          this.reset_qsearch(true);
         }
         if (this.env.action == 'compose' && this.env.extwin) {
           window.close();
@@ -1221,17 +1221,16 @@
 
       // reset quicksearch
       case 'reset-search':
-        var n, s = this.env.search_request || this.env.qsearch,
-            ss = this.gui_objects.qsearchbox && this.gui_objects.qsearchbox.value != '';
+        var n, s = this.env.search_request || this.env.qsearch;
 
-        this.reset_qsearch();
+        this.reset_qsearch(true);
         this.select_all_mode = false;
 
         if (s && this.env.action == 'compose') {
           if (this.contact_list)
             this.list_contacts_clear();
         }
-        else if (s && ss && this.env.mailbox) {
+        else if (s && this.env.mailbox) {
           this.list_mailbox(this.env.mailbox, 1);
         }
         else if (s && this.task == 'addressbook') {
@@ -2420,12 +2419,7 @@
       this.env.current_page = page;
       this.env.search_scope = 'base';
       this.select_all_mode = false;
-
-      // reset search filter
-      this.filter_disabled = true;
-      if (this.gui_objects.search_filter)
-        $(this.gui_objects.search_filter).val('ALL').change();
-      this.filter_disabled = false;
+      this.reset_search_filter();
     }
     // also send search request to get the right messages
     else if (this.env.search_request)
@@ -4341,8 +4335,17 @@
     return url;
   };
 
+  // reset search filter
+  this.reset_search_filter = function()
+  {
+    this.filter_disabled = true;
+    if (this.gui_objects.search_filter)
+      $(this.gui_objects.search_filter).val('ALL').change();
+    this.filter_disabled = false;
+  };
+
   // reset quick-search form
-  this.reset_qsearch = function()
+  this.reset_qsearch = function(all)
   {
     if (this.gui_objects.qsearchbox)
       this.gui_objects.qsearchbox.value = '';
@@ -4350,6 +4353,11 @@
     if (this.env.qsearch)
       this.abort_request(this.env.qsearch);
 
+    if (all) {
+      this.env.search_scope = 'base';
+      this.reset_search_filter();
+    }
+
     this.env.qsearch = null;
     this.env.search_request = null;
     this.env.search_id = null;

--
Gitblit v1.9.1