summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-12-16 17:18:20 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2012-12-16 17:18:20 +0000
commita085b67f865b8074bfd41800250c342c73b931ae (patch)
treeabfb8f3a94f72f700259b2642d6ef5b9ad8311f0
parentd8cf82ce9fd70e4bb383572dd0fd5cb8d48e1cfe (diff)
prevent multiple 'index locked' notifications
by keeping a "was locked" flag in the UI. Once changes are successfully flushed, we use a single "all clear" notification.
-rw-r--r--alot/commands/globals.py8
-rw-r--r--alot/ui.py2
2 files changed, 9 insertions, 1 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index 6509e554..9abadbe3 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -470,13 +470,19 @@ class FlushCommand(Command):
if callable(self.callback):
self.callback()
logging.debug('flush complete')
+ if ui.db_was_locked:
+ ui.notify('changes flushed')
+ ui.db_was_locked = False
+
except DatabaseLockedError:
timeout = settings.get('flush_retry_timeout')
def f(*args):
self.apply(ui)
ui.mainloop.set_alarm_in(timeout, f)
- ui.notify('index locked, will try again in %d secs' % timeout)
+ if not ui.db_was_locked:
+ ui.notify('index locked, will try again in %d secs' % timeout)
+ ui.db_was_locked = True
ui.update()
return
diff --git a/alot/ui.py b/alot/ui.py
index 0fa94bc9..6f6d29ed 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -29,6 +29,8 @@ class UI(object):
"""points to currently active :class:`~alot.buffers.Buffer`"""
dbman = None
"""Database Manager (:class:`~alot.db.manager.DBManager`)"""
+ db_was_locked = False
+ """flag used to prevent multiple 'index locked' notifications"""
mode = 'global'
"""interface mode identifier - type of current buffer"""
commandprompthistory = []