mirror of
https://github.com/inventree/inventree-app.git
synced 2025-05-01 06:56:50 +00:00
51 lines
1019 B
Dart
51 lines
1019 B
Dart
import "package:inventree/inventree/model.dart";
|
|
|
|
/*
|
|
* Class representing a "notification"
|
|
*/
|
|
|
|
class InvenTreeNotification extends InvenTreeModel {
|
|
|
|
InvenTreeNotification() : super();
|
|
|
|
InvenTreeNotification.fromJson(Map<String, dynamic> json) : super.fromJson(json);
|
|
|
|
@override
|
|
InvenTreeNotification createFromJson(Map<String, dynamic> json) {
|
|
return InvenTreeNotification.fromJson(json);
|
|
}
|
|
|
|
@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 {
|
|
if (jsondata.containsKey("creation")) {
|
|
return DateTime.tryParse((jsondata["creation"] ?? "") as String);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Dismiss this notification (mark as read)
|
|
*/
|
|
Future<void> dismiss() async {
|
|
|
|
await api.post(
|
|
"${url}read/",
|
|
);
|
|
|
|
}
|
|
|
|
} |