summaryrefslogtreecommitdiff
path: root/alot/commands/search.py
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-01-20 11:38:34 +0100
committerAnton Khirnov <anton@khirnov.net>2021-01-20 11:39:27 +0100
commitd47a85bca83352300399f04e76abecea4d53a934 (patch)
tree741f5ce3857102f19e4d44c33dc93981b906268d /alot/commands/search.py
parent3b78137e97565f90a48aad92dc471c47e63747eb (diff)
db: make write operations async
Diffstat (limited to 'alot/commands/search.py')
-rw-r--r--alot/commands/search.py34
1 files changed, 7 insertions, 27 deletions
diff --git a/alot/commands/search.py b/alot/commands/search.py
index 9fe265cb..d4c1a258 100644
--- a/alot/commands/search.py
+++ b/alot/commands/search.py
@@ -99,9 +99,6 @@ RetagPromptCommand = registerCommand(MODE, 'retagprompt')(RetagPromptCommand)
@registerCommand(
MODE, 'tag', forced={'action': 'add'},
arguments=[
- (['--no-flush'], {'action': 'store_false', 'dest': 'flush',
- 'default': 'True',
- 'help': 'postpone a writeout to the index'}),
(['--all'], {'action': 'store_true', 'dest': 'allmessages',
'default': False,
'help': 'tag all messages that match the current search query'}),
@@ -111,9 +108,6 @@ RetagPromptCommand = registerCommand(MODE, 'retagprompt')(RetagPromptCommand)
@registerCommand(
MODE, 'retag', forced={'action': 'set'},
arguments=[
- (['--no-flush'], {'action': 'store_false', 'dest': 'flush',
- 'default': 'True',
- 'help': 'postpone a writeout to the index'}),
(['--all'], {'action': 'store_true', 'dest': 'allmessages',
'default': False,
'help': 'retag all messages that match the current query'}),
@@ -123,9 +117,6 @@ RetagPromptCommand = registerCommand(MODE, 'retagprompt')(RetagPromptCommand)
@registerCommand(
MODE, 'untag', forced={'action': 'remove'},
arguments=[
- (['--no-flush'], {'action': 'store_false', 'dest': 'flush',
- 'default': 'True',
- 'help': 'postpone a writeout to the index'}),
(['--all'], {'action': 'store_true', 'dest': 'allmessages',
'default': False,
'help': 'untag all messages that match the current query'}),
@@ -135,9 +126,6 @@ RetagPromptCommand = registerCommand(MODE, 'retagprompt')(RetagPromptCommand)
@registerCommand(
MODE, 'toggletags', forced={'action': 'toggle'},
arguments=[
- (['--no-flush'], {'action': 'store_false', 'dest': 'flush',
- 'default': 'True',
- 'help': 'postpone a writeout to the index'}),
(['tags'], {'help': 'comma separated list of tags'})],
help='flip presence of tags on the selected thread: a tag is considered present '
'and will be removed if at least one message in this thread is '
@@ -147,8 +135,7 @@ class TagCommand(Command):
"""manipulate message tags"""
repeatable = True
- def __init__(self, tags='', action='add', allmessages=False, flush=True,
- **kwargs):
+ def __init__(self, tags='', action='add', allmessages=False, **kwargs):
"""
:param tags: comma separated list of tagstrings to set
:type tags: str
@@ -158,13 +145,10 @@ class TagCommand(Command):
:type action: str
:param allmessages: tag all messages in search result
:type allmessages: bool
- :param flush: immediately write out to the index
- :type flush: bool
"""
self.tagsstring = tags
self.action = action
self.allm = allmessages
- self.flush = flush
Command.__init__(self, **kwargs)
async def apply(self, ui):
@@ -200,11 +184,11 @@ class TagCommand(Command):
try:
if self.action == 'add':
- ui.dbman.tag(testquery, tags, remove_rest=False)
+ await ui.dbman.tags_add(testquery, tags)
if self.action == 'set':
- ui.dbman.tag(testquery, tags, remove_rest=True)
+ await ui.dbman.tags_set(testquery, tags)
elif self.action == 'remove':
- ui.dbman.untag(testquery, tags)
+ await ui.dbman.tags_remove(testquery, tags)
elif self.action == 'toggle':
if not self.allm:
to_remove = set()
@@ -214,17 +198,13 @@ class TagCommand(Command):
to_remove.add(t)
else:
to_add.add(t)
- thread.remove_tags(to_remove)
- thread.add_tags(to_add, afterwards=refresh)
+ await thread.tags_remove(to_remove)
+ await thread.tags_add(to_add)
except DatabaseROError:
ui.notify('index in read-only mode', priority='error')
return
- # flush index
- if self.flush:
- await ui.apply_command(
- commands.globals.FlushCommand(callback=refresh))
-
+ refresh()
@registerCommand(
MODE, 'move', help='move focus in search buffer',