From 71d9ac0adc42caed683647ca58db7c6b1e219f2f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 2 May 2017 09:18:17 +0530 Subject: [PATCH] Change notification for saved searches --- src/calibre/db/cli/cmd_saved_searches.py | 5 +++++ src/calibre/srv/changes.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/calibre/db/cli/cmd_saved_searches.py b/src/calibre/db/cli/cmd_saved_searches.py index 686ea16246..62949836f3 100644 --- a/src/calibre/db/cli/cmd_saved_searches.py +++ b/src/calibre/db/cli/cmd_saved_searches.py @@ -8,6 +8,7 @@ readonly = False version = 0 # change this if you change signature of implementation() from calibre import prints +from calibre.srv.changes import saved_searches def implementation(db, notify_changes, action, *args): @@ -18,10 +19,14 @@ def implementation(db, notify_changes, action, *args): if action == 'add': name, val = args db.saved_search_add(name, val) + if notify_changes is not None: + notify_changes(saved_searches([('add', name)])) return if action == 'remove': name = args[0] db.saved_search_delete(name) + if notify_changes is not None: + notify_changes(saved_searches([('remove', name)])) return diff --git a/src/calibre/srv/changes.py b/src/calibre/srv/changes.py index a643e478ea..4d7d413161 100644 --- a/src/calibre/srv/changes.py +++ b/src/calibre/srv/changes.py @@ -25,3 +25,9 @@ def books_deleted(book_ids): def metadata(book_ids): pass + + +def saved_searches(changes): + for change_type, saved_search_name in changes: + # change_type is one of 'add' or 'remove' + pass