Check that notification target is not null (#3449)

* Check that target is not null

* Prevent display of "negative" notification coutner

* spelling fix
This commit is contained in:
Oliver 2022-08-01 14:25:24 +10:00 committed by GitHub
parent ee18ce9a7a
commit 6118d1319c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -161,8 +161,8 @@ class NotificationMessageSerializer(InvenTreeModelSerializer):
"""Function to resolve generic object reference to target."""
target = get_objectreference(obj, 'target_content_type', 'target_object_id')
if 'link' not in target:
# Check if objekt has an absolute_url function
if target and 'link' not in target:
# Check if object has an absolute_url function
if hasattr(obj.target_object, 'get_absolute_url'):
target['link'] = obj.target_object.get_absolute_url()
else:
@ -174,6 +174,7 @@ class NotificationMessageSerializer(InvenTreeModelSerializer):
f'admin:{meta.db_table}_change',
kwargs={'object_id': obj.target_object_id}
))
return target
def get_source(self, obj):

View File

@ -174,6 +174,12 @@ function updateNotificationReadState(btn, panel_caller=false) {
} else {
count = count + 1;
}
// Prevent negative notification count
if (count < 0) {
count = 0;
}
// update notification indicator now
updateNotificationIndicator(count);