Skip to content

Commit

Permalink
Fixed shuffleboard api data not resetting on disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Nov 8, 2023
1 parent bbe8d7a commit 32ef712
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/services/shuffleboard_nt_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class ShuffleboardNTListener {
previousSelection = data;
});

nt4Connection.addDisconnectedListener(() {
currentJsonData.clear();
shuffleboardTreeRoot.clearRows();
previousSelection = null;
});

nt4Connection.nt4Client.addTopicAnnounceListener((topic) async {
if (!topic.name.contains(shuffleboardTableRoot)) {
return;
Expand Down Expand Up @@ -146,6 +152,8 @@ class ShuffleboardNTListener {
.putIfAbsent('children', () => <Map<String, dynamic>>[]);

_createOrGetChild(jsonKey, widgetName);

print('Adding child: $widgetName');
} else {
currentJsonData[jsonKey]!.putIfAbsent('layout', () => false);

Expand Down
4 changes: 4 additions & 0 deletions lib/widgets/network_tree/tree_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class TreeRow {
}
}

void clearRows() {
children.clear();
}

static NT4Widget? getNT4WidgetFromTopic(NT4Topic nt4Topic) {
switch (nt4Topic.type) {
case NT4TypeStr.kFloat64:
Expand Down

0 comments on commit 32ef712

Please sign in to comment.