feat: integrate YOLO runtime, update screens, and sync docs
This commit is contained in:
@@ -40,7 +40,7 @@ class _NotificationScreenState extends State<NotificationScreen> {
|
||||
final res = await _api
|
||||
.get('/user/notifications')
|
||||
.timeout(const Duration(seconds: 10));
|
||||
final list = (res.data['data'] as List?) ?? [];
|
||||
final list = _extractList(res.data);
|
||||
setState(() {
|
||||
_items = list.map((e) => _NotifItem.fromJson(e)).toList();
|
||||
});
|
||||
@@ -56,10 +56,20 @@ class _NotificationScreenState extends State<NotificationScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> _extractList(dynamic responseBody) {
|
||||
final data = responseBody is Map ? responseBody['data'] : null;
|
||||
final rawList = data is Map ? data['content'] : data;
|
||||
if (rawList is! List) return const [];
|
||||
return rawList
|
||||
.whereType<Map>()
|
||||
.map((item) => Map<String, dynamic>.from(item))
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<void> _markRead(int id) async {
|
||||
try {
|
||||
await _api
|
||||
.patch('/user/notifications/$id/read')
|
||||
.put('/user/notifications/$id/read')
|
||||
.timeout(const Duration(seconds: 6));
|
||||
setState(() {
|
||||
final idx = _items.indexWhere((n) => n.id == id);
|
||||
@@ -72,7 +82,7 @@ class _NotificationScreenState extends State<NotificationScreen> {
|
||||
setState(() => _markingAll = true);
|
||||
try {
|
||||
await _api
|
||||
.patch('/user/notifications/read-all')
|
||||
.put('/user/notifications/mark-all-read')
|
||||
.timeout(const Duration(seconds: 8));
|
||||
setState(() {
|
||||
_items = _items.map((n) => n.copyWith(isRead: true)).toList();
|
||||
|
||||
Reference in New Issue
Block a user