From d11069a2be1fdd31104b0d5d6aad9d5c3633234b Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 26 Feb 2025 00:00:53 +0800 Subject: [PATCH] :bug: Bug fixes on notification page --- lib/screens/notification.dart | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/screens/notification.dart b/lib/screens/notification.dart index b856bc1..8cb2127 100644 --- a/lib/screens/notification.dart +++ b/lib/screens/notification.dart @@ -29,6 +29,7 @@ const Map kNotificationTopicIcons = { 'passport.security.otp': Symbols.password, 'interactive.subscription': Symbols.subscriptions, 'interactive.feedback': Symbols.add_reaction, + 'interactive.reply': Symbols.reply, 'messaging.callStart': Symbols.call_received, 'wallet.transaction.new': Symbols.receipt, }; @@ -57,10 +58,17 @@ class _NotificationScreenState extends State { try { final sn = context.read(); final nty = context.read(); - final resp = await sn.client.get('/cgi/id/notifications?take=10'); + final resp = + await sn.client.get('/cgi/id/notifications', queryParameters: { + 'take': 10, + 'offset': _notifications.length, + }); _totalCount = resp.data['count']; _notifications.addAll( - resp.data['data']?.map((e) => SnNotification.fromJson(e)).cast() ?? [], + resp.data['data'] + ?.map((e) => SnNotification.fromJson(e)) + .cast() ?? + [], ); nty.updateTray(); } catch (err) { @@ -186,7 +194,8 @@ class _NotificationScreenState extends State { _fetchNotifications(); }, isLoading: _isBusy, - hasReachedMax: _totalCount != null && _notifications.length >= _totalCount!, + hasReachedMax: _totalCount != null && + _notifications.length >= _totalCount!, itemBuilder: (context, idx) { final nty = _notifications[idx]; return Row( @@ -218,13 +227,17 @@ class _NotificationScreenState extends State { isAutoWarp: true, ), ), - if (['interactive.reply', 'interactive.feedback', 'interactive.subscription'] - .contains(nty.topic) && + if ([ + 'interactive.reply', + 'interactive.feedback', + 'interactive.subscription' + ].contains(nty.topic) && nty.metadata['related_post'] != null) GestureDetector( child: Container( decoration: BoxDecoration( - borderRadius: const BorderRadius.all(Radius.circular(8)), + borderRadius: const BorderRadius.all( + Radius.circular(8)), border: Border.all( color: Theme.of(context).dividerColor, width: 1, @@ -243,7 +256,9 @@ class _NotificationScreenState extends State { GoRouter.of(context).pushNamed( 'postDetail', pathParameters: { - 'slug': nty.metadata['related_post']!['id'].toString(), + 'slug': nty + .metadata['related_post']!['id'] + .toString(), }, ); }, @@ -272,8 +287,10 @@ class _NotificationScreenState extends State { IconButton( icon: const Icon(Symbols.check), padding: EdgeInsets.all(0), - visualDensity: const VisualDensity(horizontal: -4, vertical: -4), - onPressed: _isSubmitting ? null : () => _markOneAsRead(nty), + visualDensity: + const VisualDensity(horizontal: -4, vertical: -4), + onPressed: + _isSubmitting ? null : () => _markOneAsRead(nty), ), ], ).padding(horizontal: 16);