send updated bookmarks to clients on the fly

This commit is contained in:
Jakob Ketterl
2021-03-25 15:25:15 +01:00
parent 20cd3f6efe
commit 287a04be94
3 changed files with 57 additions and 3 deletions

View File

@ -88,6 +88,8 @@ class BookmarksController(AuthorizationMixin, WebpageController):
value = int(value)
setattr(bookmark, key, value)
Bookmarks.getSharedInstance().store()
# TODO this should not be called explicitly... bookmarks don't have any event capability right now, though
Bookmarks.getSharedInstance().notifySubscriptions(bookmark)
self.send_response("{}", content_type="application/json", code=200)
except json.JSONDecodeError:
self.send_response("{}", content_type="application/json", code=400)
@ -97,7 +99,11 @@ class BookmarksController(AuthorizationMixin, WebpageController):
try:
data = json.loads(self.get_body())
# sanitize
data = {k: data[k] for k in ["name", "frequency", "modulation"]}
data = {
"name": data["name"],
"frequency": int(data["frequency"]),
"modulation": data["modulation"],
}
bookmark = Bookmark(data)
bookmarks.addBookmark(bookmark)