nncli

NextCloud Notes Command Line Interface
git clone git://git.danielmoch.com/nncli.git
Log | Files | Refs | LICENSE

commit 143aa40944eddbb7b70ccb424364205ac5e147da
parent 22697928ae7e63ae8d69b0dd08f3c5f884142ead
Author: Eric Davis <edavis@insanum.com>
Date:   Wed,  9 Jul 2014 23:47:15 -0700

update the note and note list views after changes occurred from a sync

Diffstat:
Mnotes_db.py | 11++++++++---
Msncli.py | 15++++++++++++++-
Mview_titles.py | 5+++++
3 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/notes_db.py b/notes_db.py @@ -17,9 +17,10 @@ class WriteError(RuntimeError): class NotesDB(): """NotesDB will take care of the local notes database and syncing with SN. """ - def __init__(self, config, log): - self.config = config - self.log = log + def __init__(self, config, log, update_view): + self.config = config + self.log = log + self.update_view = update_view self.last_sync = 0 # set to zero to trigger a full sync self.sync_lock = threading.Lock() @@ -555,6 +556,10 @@ def sync_notes(self, server_sync=True, full_sync=True): if not sync_errors: self.last_sync = sync_start_time + # if there were any changes then update the current view + if len(local_updates) > 0 or len(local_deletes) > 0: + self.update_view() + if server_sync and full_sync: self.log("Full sync completed") diff --git a/sncli.py b/sncli.py @@ -34,7 +34,7 @@ def __init__(self): self.logs = [] try: - self.ndb = NotesDB(self.config, self.log) + self.ndb = NotesDB(self.config, self.log, self.gui_update_view) except Exception, e: self.log(str(e)) sys.exit(1) @@ -157,6 +157,19 @@ def log(self, msg): self.log_lock.release() + def gui_update_view(self): + if not self.do_gui: + return + + cur_key = self.view_titles.note_list[self.view_titles.focus_position].note['key'] + self.view_titles.update_note_list(self.view_titles.search_string) + self.view_titles.focus_note(cur_key) + + if self.gui_body_get().__class__ == view_note.ViewNote: + self.view_note.update_note(self.view_note.note['key']) + + self.gui_update_status_bar() + def gui_update_status_bar(self): if self.status_bar != 'yes': self.gui_header_clear() diff --git a/view_titles.py b/view_titles.py @@ -182,6 +182,11 @@ def update_note_title(self, key): if self.note_list[i].note['key'] == key: self.body[i] = self.get_note_title(self.note_list[i].note) + def focus_note(self, key): + for i in xrange(len(self.note_list)): + if self.note_list[i].note['key'] == key: + self.focus_position = i + def keypress(self, size, key): return key