Skip to content

Commit

Permalink
Prevent shuffleboard widgets from being added when NT is disconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Dec 11, 2023
1 parent d38fe3f commit 7c50a93
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/services/shuffleboard_nt_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ class ShuffleboardNTListener {
previousSelection = data;
});

// Also clear data when connected in case if threads auto populate json after disconnection
// Chances are low since the timing has to be just right but you never know
nt4Connection.addConnectedListener(() {
currentJsonData.clear();
shuffleboardTreeRoot.clearRows();
previousSelection = null;
});

nt4Connection.addDisconnectedListener(() {
currentJsonData.clear();
shuffleboardTreeRoot.clearRows();
Expand Down Expand Up @@ -368,7 +376,9 @@ class ShuffleboardNTListener {
? Settings.defaultPeriod
: Settings.defaultGraphPeriod);

onWidgetAdded?.call(currentJsonData[jsonKey]!);
if (nt4Connection.isNT4Connected) {
onWidgetAdded?.call(currentJsonData[jsonKey]!);
}

widget?.unSubscribe();
widget?.dispose(deleting: true);
Expand Down Expand Up @@ -467,8 +477,9 @@ class ShuffleboardNTListener {
widget?.unSubscribe();
widget?.dispose(deleting: true);
}

onWidgetAdded?.call(currentJsonData[jsonKey]!);
if (nt4Connection.isNT4Connected) {
onWidgetAdded?.call(currentJsonData[jsonKey]!);
}
});
}

Expand Down

0 comments on commit 7c50a93

Please sign in to comment.