Allow notifying a set of changed notes in a single event

This commit is contained in:
Kovid Goyal 2025-04-03 08:02:52 +05:30
parent 6359c0593f
commit ccbcd938f2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 4 deletions

View File

@ -717,7 +717,7 @@ class Cache:
resources, note that updating a note automatically cleans up resources pertaining to that note anyway. resources, note that updating a note automatically cleans up resources pertaining to that note anyway.
''' '''
ans = self.backend.set_notes_for(field, item_id, doc, searchable_text, resource_hashes, remove_unused_resources) ans = self.backend.set_notes_for(field, item_id, doc, searchable_text, resource_hashes, remove_unused_resources)
self.event_dispatcher(EventType.notes_changed, field, item_id) self.event_dispatcher(EventType.notes_changed, field, {item_id})
return ans return ans
@write_api @write_api
@ -739,7 +739,7 @@ class Cache:
def unretire_note_for(self, field, item_id) -> int: def unretire_note_for(self, field, item_id) -> int:
' Unretire a previously retired note for the specified item. Notes are retired when an item is removed from the database ' ' Unretire a previously retired note for the specified item. Notes are retired when an item is removed from the database '
ans = self.backend.unretire_note_for(field, item_id) ans = self.backend.unretire_note_for(field, item_id)
self.event_dispatcher(EventType.notes_changed, field, item_id) self.event_dispatcher(EventType.notes_changed, field, {item_id})
return ans return ans
@read_api @read_api
@ -761,7 +761,7 @@ class Cache:
ctime, mtime = st.st_ctime, st.st_mtime ctime, mtime = st.st_ctime, st.st_mtime
basedir = os.path.dirname(os.path.abspath(path_to_html_file)) basedir = os.path.dirname(os.path.abspath(path_to_html_file))
ans = self.backend.import_note(field, item_id, html, basedir, ctime, mtime) ans = self.backend.import_note(field, item_id, html, basedir, ctime, mtime)
self.event_dispatcher(EventType.notes_changed, field, item_id) self.event_dispatcher(EventType.notes_changed, field, {item_id})
return ans return ans
@write_api # we need to use write locking as SQLITE gives a locked table error if multiple FTS queries are made at the same time @write_api # we need to use write locking as SQLITE gives a locked table error if multiple FTS queries are made at the same time

View File

@ -43,7 +43,7 @@ class EventType(Enum):
#: When the indexing progress changes #: When the indexing progress changes
indexing_progress_changed = auto() indexing_progress_changed = auto()
#: When the notes associated with an item are changed, with arguments: (field_name, item_id) #: When the notes associated with an item are changed, with arguments: (field_name, item_ids)
notes_changed = auto() notes_changed = auto()