From 971c6bfcdb2fba63d7d877bdd647a6fd5b60dc62 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 4 Dec 2022 23:01:11 +1100 Subject: [PATCH] Update API for marking a notification as "read" (#228) --- lib/inventree/notification.dart | 10 ++++++---- lib/widget/notifications.dart | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/inventree/notification.dart b/lib/inventree/notification.dart index c6b74049..a533319b 100644 --- a/lib/inventree/notification.dart +++ b/lib/inventree/notification.dart @@ -42,10 +42,12 @@ class InvenTreeNotification extends InvenTreeModel { */ Future dismiss() async { - await api.post( - "${url}read/", - ); - + if (api.apiVersion >= 82) { + // "Modern" API endpoint operates a little differently + await update(values: {"read": "true"}); + } else { + await api.post("${url}read/"); + } } } \ No newline at end of file diff --git a/lib/widget/notifications.dart b/lib/widget/notifications.dart index 0af32b8b..23b8bd65 100644 --- a/lib/widget/notifications.dart +++ b/lib/widget/notifications.dart @@ -43,6 +43,9 @@ class _NotificationState extends RefreshableState { } } + /* + * Dismiss an individual notification entry (mark it as "read") + */ Future dismissNotification(BuildContext context, InvenTreeNotification notification) async { await notification.dismiss(); @@ -51,6 +54,9 @@ class _NotificationState extends RefreshableState { } + /* + * Display an individual notification message + */ List renderNotifications(BuildContext context) { List tiles = [];