File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed
Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,6 @@ class _NotificationPageState extends State<NotificationPage> with SingleTickerPr
8181 Widget build (BuildContext context) {
8282 final tr = context.t.noticePage;
8383 return BlocListener <NotificationBloc , NotificationState >(
84- listenWhen: (prev, curr) => prev.status != curr.status,
8584 listener: (context, state) {
8685 if (state.status == NotificationStatus .failure) {
8786 showFailedToLoadSnackBar (context);
@@ -94,11 +93,6 @@ class _NotificationPageState extends State<NotificationPage> with SingleTickerPr
9493 personalMessageCount: pm,
9594 broadcastMessageCount: bm,
9695 );
97-
98- // Update last fetch notification time.
99- if (state.latestTime != null ) {
100- context.read <NotificationBloc >().add (NotificationRecordFetchTimeRequested (state.latestTime! ));
101- }
10296 }
10397 },
10498 child: BlocBuilder <NotificationBloc , NotificationState >(
Original file line number Diff line number Diff line change @@ -71,12 +71,20 @@ class _RootPageState extends State<RootPage> with LoggerMixin {
7171 },
7272 ),
7373 BlocListener <NotificationBloc , NotificationState >(
74- listenWhen: (_, curr) => curr.status == NotificationStatus .loading,
75- listener: (context, _) {
76- final autoSyncState = context.read <AutoNotificationCubit >();
77- if (autoSyncState.state is AutoNoticeStateTicking ) {
78- // Restart the auto notification sync process.
79- context.read <AutoNotificationCubit >().restart ();
74+ listener: (context, state) {
75+ if (state.status == NotificationStatus .loading) {
76+ final autoSyncState = context.read <AutoNotificationCubit >();
77+ if (autoSyncState.state is AutoNoticeStateTicking ) {
78+ // Restart the auto notification sync process.
79+ context.read <AutoNotificationCubit >().restart ();
80+ }
81+ } else if (state.status == NotificationStatus .success) {
82+ // Update last fetch notification time.
83+ // We do it here because it's a global action lives in the entire lifetime of the app, not only when
84+ // the notification page is live. This fixes the critical issue where time not updated.
85+ if (state.latestTime != null ) {
86+ context.read <NotificationBloc >().add (NotificationRecordFetchTimeRequested (state.latestTime! ));
87+ }
8088 }
8189 },
8290 ),
You can’t perform that action at this time.
0 commit comments