Merge pull request #17024 from gavindsouza/misc-fixes-9

fix: Update modified timestamp on Notification Settings (only when needed)
This commit is contained in:
gavin 2022-05-31 14:39:53 +05:30 committed by GitHub
commit 8212aefdf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

@ -148,6 +148,6 @@ def trigger_indicator_hide():
def set_notifications_as_unseen(user):
try:
frappe.db.set_value("Notification Settings", user, "seen", 0)
frappe.db.set_value("Notification Settings", user, "seen", 0, update_modified=False)
except frappe.DoesNotExistError:
return

View file

@ -48,9 +48,15 @@ def create_notification_settings(user):
_doc.insert(ignore_permissions=True)
def toggle_notifications(user, enable=False):
if frappe.db.exists("Notification Settings", user):
frappe.db.set_value("Notification Settings", user, "enabled", enable)
def toggle_notifications(user: str, enable: bool = False):
try:
settings = frappe.get_doc("Notification Settings", user)
except frappe.DoesNotExistError:
return
if settings.enabled != enable:
settings.enabled = enable
settings.save()
@frappe.whitelist()