Implemented per stream subscription recovery with polling fallback

This commit is contained in:
2026-03-01 17:24:04 +08:00
parent e91e7b43d2
commit c9479f01f0
19 changed files with 894 additions and 494 deletions
+4 -5
View File
@@ -4,7 +4,6 @@ import 'package:firebase_messaging/firebase_messaging.dart';
import '../models/notification_item.dart';
import '../providers/notifications_provider.dart';
import '../providers/realtime_controller.dart';
/// Wraps the app and installs both a Supabase realtime listener and the
/// FCM handlers described in the frontend design.
@@ -46,11 +45,11 @@ class _NotificationBridgeState extends ConsumerState<NotificationBridge>
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
// App lifecycle is now monitored, but individual streams handle their own
// recovery via StreamRecoveryWrapper. This no longer forces a global reconnect,
// which was the blocking behavior users complained about.
if (state == AppLifecycleState.resumed) {
try {
// Trigger a best-effort realtime reconnection when the app resumes.
ref.read(realtimeControllerProvider).recoverConnection();
} catch (_) {}
// Future: Could trigger stream-specific recovery hints if needed.
}
}