diff --git a/client/deepdame/lib/core/network/stomp_service.dart b/client/deepdame/lib/core/network/stomp_service.dart index 16681aa8..1bb63308 100644 --- a/client/deepdame/lib/core/network/stomp_service.dart +++ b/client/deepdame/lib/core/network/stomp_service.dart @@ -70,8 +70,10 @@ class StompService { Stream> subscribe(String destination) { final controller = StreamController>.broadcast(); void Function()? unsubscribe; + StreamSubscription? stateSub; void doSubscribe() { + unsubscribe?.call(); unsubscribe = _client?.subscribe( destination: destination, callback: (frame) { @@ -85,19 +87,19 @@ class StompService { ); } - if (isConnected) { - doSubscribe(); - } else { - late StreamSubscription sub; - sub = state.listen((s) { - if (s == StompState.connected) { - doSubscribe(); - unawaited(sub.cancel()); - } - }); - } + // Keep the listener alive for the full stream lifetime so every + // reconnect re-registers the subscription with the new STOMP session. + stateSub = state.listen((s) { + if (s == StompState.connected) doSubscribe(); + }); + + if (isConnected) doSubscribe(); + + controller.onCancel = () { + unsubscribe?.call(); + unawaited(stateSub?.cancel()); + }; - controller.onCancel = () => unsubscribe?.call(); return controller.stream; } diff --git a/client/deepdame/lib/features/settings/settings_screen.dart b/client/deepdame/lib/features/settings/settings_screen.dart index e571d468..e588b1a1 100644 --- a/client/deepdame/lib/features/settings/settings_screen.dart +++ b/client/deepdame/lib/features/settings/settings_screen.dart @@ -487,7 +487,7 @@ class _LogoutTile extends ConsumerWidget { if (confirmed != true) return; await ref.read(authControllerProvider.notifier).logout(); - // Router redirect handles navigation to the login screen + if (context.mounted) context.goNamed('login'); } } diff --git a/client/deepdame/pubspec.yaml b/client/deepdame/pubspec.yaml index 78a2e04e..a61e6281 100644 --- a/client/deepdame/pubspec.yaml +++ b/client/deepdame/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 2.0.24+25 +version: 2.0.25+26 environment: sdk: ^3.10.4