]> git.neil.brown.name Git - edlib.git/commitdiff
notmuch: refresh query on "doc:closed" rather than "Close" on view.
authorNeilBrown <neil@brown.name>
Thu, 14 Sep 2023 04:01:31 +0000 (14:01 +1000)
committerNeilBrown <neil@brown.name>
Fri, 15 Sep 2023 03:38:14 +0000 (13:38 +1000)
When a view is closed, doc:closed is sent to the document.  This seems
like a slightly better way to trigger the "no-one is watching so
refresh", rather than on "Close" from the view - though both work.

Signed-off-by: NeilBrown <neil@brown.name>
python/module-notmuch.py

index a24115f2580c2d86ea4bde9df44e1ea483f0de8e..0f7cc11fbdfb0bec64996d38f8740b0cd181c638 100644 (file)
@@ -1791,6 +1791,18 @@ class notmuch_query(edlib.Doc):
         self.maindoc.call(key, str, str2)
         return 1
 
+    def handle_doc_closed(self, key, **a):
+        "handle:doc:closed"
+        # A view on this query has been closed, so now is a good
+        # time to update the list (prune all archived threads) and
+        # the counts.
+        if self.notify("doc:notify-viewers") == 0:
+            self.load_full()
+        self.maindoc.call("doc:notmuch:update-one", self['qname'])
+
+        # contine to default handling.
+        return edlib.Efallthrough
+
 class tag_popup(edlib.Pane):
     def __init__(self, focus):
         edlib.Pane.__init__(self, focus)
@@ -2689,14 +2701,6 @@ class notmuch_query_view(edlib.Pane):
         self.clone_children(focus.focus)
         return 1
 
-    def handle_close(self, key, focus, **a):
-        "handle:Close"
-
-        # Reload the query so archived messages disappear
-        self.call("doc:notmuch:query:reload")
-        self.call("doc:notmuch:update-one", self['qname'])
-        return 1
-
     def handle_matched_mids(self, key, focus, str, str2, comm2, **a):
         "handle-prefix:doc:notmuch-query:matched-"
         # if whole_thread, everything should be considered matched.