mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Adds ability to "dismiss" a notification
This commit is contained in:
parent
6bbae67482
commit
020f006410
@ -18,6 +18,15 @@ class InvenTreeNotification extends InvenTreeModel {
|
||||
@override
|
||||
String get URL => "notifications/";
|
||||
|
||||
@override
|
||||
Map<String, String> defaultListFilters() {
|
||||
|
||||
// By default, only return 'unread' notifications
|
||||
return {
|
||||
"read": "false",
|
||||
};
|
||||
}
|
||||
|
||||
String get message => (jsondata["message"] ?? "") as String;
|
||||
|
||||
DateTime? get creationDate {
|
||||
@ -28,4 +37,15 @@ class InvenTreeNotification extends InvenTreeModel {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Dismiss this notification (mark as read)
|
||||
*/
|
||||
Future<void> dismiss() async {
|
||||
|
||||
final response = await api.post(
|
||||
"${url}read/",
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -533,7 +533,7 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
Map<String, dynamic> data = {};
|
||||
|
||||
// Note: Format of adjustment API was updated in API v14
|
||||
if (InvenTreeAPI().supportModernStockTransactions()) {
|
||||
if (api.supportModernStockTransactions()) {
|
||||
// Modern (> 14) API
|
||||
data = {
|
||||
"items": [
|
||||
@ -560,7 +560,7 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
}
|
||||
|
||||
// Expected API return code depends on server API version
|
||||
final int expected_response = InvenTreeAPI().supportModernStockTransactions() ? 201 : 200;
|
||||
final int expected_response = api.supportModernStockTransactions() ? 201 : 200;
|
||||
|
||||
var response = await api.post(
|
||||
endpoint,
|
||||
|
@ -36,6 +36,8 @@ class _NotificationState extends RefreshableState<NotificationWidget> {
|
||||
|
||||
final results = await InvenTreeNotification().list();
|
||||
|
||||
notifications.clear();
|
||||
|
||||
for (InvenTreeModel n in results) {
|
||||
if (n is InvenTreeNotification) {
|
||||
notifications.add(n);
|
||||
@ -43,6 +45,14 @@ class _NotificationState extends RefreshableState<NotificationWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> dismissNotification(BuildContext context, InvenTreeNotification notification) async {
|
||||
|
||||
await notification.dismiss();
|
||||
|
||||
refresh(context);
|
||||
|
||||
}
|
||||
|
||||
List<Widget> renderNotifications(BuildContext context) {
|
||||
|
||||
List<Widget> tiles = [];
|
||||
@ -66,7 +76,7 @@ class _NotificationState extends RefreshableState<NotificationWidget> {
|
||||
trailing: IconButton(
|
||||
icon: FaIcon(FontAwesomeIcons.bookmark),
|
||||
onPressed: () async {
|
||||
|
||||
dismissNotification(context, notification);
|
||||
},
|
||||
),
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user