summaryrefslogtreecommitdiff
path: root/alot/db/thread.py
diff options
context:
space:
mode:
Diffstat (limited to 'alot/db/thread.py')
-rw-r--r--alot/db/thread.py54
1 files changed, 12 insertions, 42 deletions
diff --git a/alot/db/thread.py b/alot/db/thread.py
index 2b580dcf..1f9ae7f0 100644
--- a/alot/db/thread.py
+++ b/alot/db/thread.py
@@ -63,7 +63,7 @@ class Thread:
self.refresh(thread)
- def refresh(self, thread=None):
+ def refresh(self, thread = None):
"""refresh thread metadata from the index"""
if not thread:
thread = self._dbman._get_notmuch_thread(self.id)
@@ -140,58 +140,28 @@ class Thread:
tags = tags.intersection(set(m.get_tags()))
return tags
- def add_tags(self, tags, afterwards=None, remove_rest=False):
+ def tags_add(self, tags):
"""
- add `tags` to all messages in this thread
-
- .. note::
-
- This only adds the requested operation to this objects
- :class:`DBManager's <alot.db.DBManager>` write queue.
- You need to call :meth:`DBManager.flush <alot.db.DBManager.flush>`
- to actually write out.
+ Asynchronously add `tags` to all messages in this thread
:param tags: a set of tags to be added
:type tags: set of str
- :param afterwards: callback that gets called after successful
- application of this tagging operation
- :type afterwards: callable
- :param remove_rest: remove all other tags
- :type remove_rest: bool
"""
- def myafterwards():
- self.refresh()
- if callable(afterwards):
- afterwards()
- self._dbman.tag('thread:' + self.id, tags, afterwards=myafterwards,
- remove_rest=remove_rest)
+ fut = self._dbman.tags_add('thread:' + self.id, tags)
+ fut.add_done_callback(lambda fut: self.refresh())
+ return fut
- def remove_tags(self, tags, afterwards=None):
+ def tags_remove(self, tags):
"""
- remove `tags` (list of str) from all messages in this thread
-
- .. note::
-
- This only adds the requested operation to this objects
- :class:`DBManager's <alot.db.DBManager>` write queue.
- You need to call :meth:`DBManager.flush <alot.db.DBManager.flush>`
- to actually write out.
-
+ Asynchronously remove `tags` from all messages in this thread
:param tags: a set of tags to be added
:type tags: set of str
- :param afterwards: callback that gets called after successful
- application of this tagging operation
- :type afterwards: callable
"""
- rmtags = set(tags).intersection(self._tags)
- if rmtags:
-
- def myafterwards():
- self.refresh()
- if callable(afterwards):
- afterwards()
- self._dbman.untag('thread:' + self.id, tags, myafterwards)
+ fut = self._dbman.tags_remove('thread:' + self.id, tags)
+ fut.add_done_callback(lambda fut: self.refresh())
+ return fut
+
def get_authors(self):
"""