Change notification for saved searches

This commit is contained in:
Kovid Goyal 2017-05-02 09:18:17 +05:30
parent 7ebd16989d
commit 71d9ac0adc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 11 additions and 0 deletions

View File

@ -8,6 +8,7 @@ readonly = False
version = 0 # change this if you change signature of implementation() version = 0 # change this if you change signature of implementation()
from calibre import prints from calibre import prints
from calibre.srv.changes import saved_searches
def implementation(db, notify_changes, action, *args): def implementation(db, notify_changes, action, *args):
@ -18,10 +19,14 @@ def implementation(db, notify_changes, action, *args):
if action == 'add': if action == 'add':
name, val = args name, val = args
db.saved_search_add(name, val) db.saved_search_add(name, val)
if notify_changes is not None:
notify_changes(saved_searches([('add', name)]))
return return
if action == 'remove': if action == 'remove':
name = args[0] name = args[0]
db.saved_search_delete(name) db.saved_search_delete(name)
if notify_changes is not None:
notify_changes(saved_searches([('remove', name)]))
return return

View File

@ -25,3 +25,9 @@ def books_deleted(book_ids):
def metadata(book_ids): def metadata(book_ids):
pass pass
def saved_searches(changes):
for change_type, saved_search_name in changes:
# change_type is one of 'add' or 'remove'
pass