Skip to content

Commit

Permalink
Don't clear cached values until reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Sep 12, 2023
1 parent 0cc5154 commit 2adc8fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions lib/services/nt4.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,14 @@ class NT4Client {
// Prevents repeated calls to onConnect and reconnecting after changing ip addresses
if (!_serverConnectionActive &&
serverAddr.contains(serverBaseAddress)) {
lastAnnouncedValues.clear();

for (NT4Subscription sub in _subscriptions.values) {
sub.currentValue = null;
}

_serverConnectionActive = true;

onConnect?.call();
}
_wsOnMessage(data);
Expand Down Expand Up @@ -345,12 +352,6 @@ class NT4Client {

announcedTopics.clear();

lastAnnouncedValues.clear();

for (NT4Subscription sub in _subscriptions.values) {
sub.currentValue = null;
}

if (kDebugMode) {
print('[NT4] Connection closed. Attempting to reconnect in 1s');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/nt4_widgets/multi-topic/camera_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class CameraStreamWidget extends StatelessWidget with NT4Widget {
streams.add(stream.substring(5));
}

if (streams.isEmpty) {
if (streams.isEmpty || !nt4Connection.isNT4Connected) {
return Stack(
fit: StackFit.expand,
children: [
Expand Down

0 comments on commit 2adc8fd

Please sign in to comment.