mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Add mark all as read action to notifications list
Shows a done_all icon button in the AppBar when the New filter is active and the list is non-empty, calling the notifications/mark_all_as_old endpoint. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
bda7b87cc7
commit
6002597383
@@ -32,6 +32,20 @@ class _NotificationListState extends State<NotificationList> {
|
||||
},
|
||||
);
|
||||
|
||||
Future<void> _markAllAsRead(BuildContext context) async {
|
||||
await BackendAPI.instance.markAllNotificationsAsRead();
|
||||
_pagingController.refresh();
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('All notifications marked as read'),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
showCloseIcon: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> _markAsRead(
|
||||
BuildContext context,
|
||||
oott_model.Notification item,
|
||||
@@ -102,13 +116,22 @@ class _NotificationListState extends State<NotificationList> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Notifications')),
|
||||
body:
|
||||
// Paginated list start
|
||||
PagingListener(
|
||||
return PagingListener(
|
||||
controller: _pagingController,
|
||||
builder: (context, state, fetchNextPage) => CustomScrollView(
|
||||
builder: (context, state, fetchNextPage) => Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Notifications'),
|
||||
actions: [
|
||||
if (_filterChoice == 1 && (state.items?.isNotEmpty ?? false))
|
||||
IconButton(
|
||||
onPressed: () => _markAllAsRead(context),
|
||||
icon: const Icon(Icons.done_all),
|
||||
tooltip: 'Mark all as read',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
// Filters go here
|
||||
SliverToBoxAdapter(
|
||||
|
||||
@@ -76,6 +76,11 @@ class BackendAPI {
|
||||
await _dio.post('/notifications/$id/mark_as_new');
|
||||
}
|
||||
|
||||
Future<void> markAllNotificationsAsRead() async {
|
||||
print('About to call /notifications/mark_all_as_old');
|
||||
await _dio.post('/notifications/mark_all_as_old');
|
||||
}
|
||||
|
||||
Future<List<Notification>> listNotifications(bool? isNew, int offset) async {
|
||||
print('About to call /notifications');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user