Skip to content

Commit

Permalink
Only reset network when settings change
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Nov 22, 2024
1 parent 8cb5bff commit ee0ba06
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/src/models/view/builders/settings_builder.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "package:collection/collection.dart";
import "package:flutter/material.dart";
import "package:rover_dashboard/data.dart";
import "package:rover_dashboard/models.dart";
Expand Down Expand Up @@ -377,8 +378,14 @@ class SettingsBuilder extends ValueBuilder<Settings> {
// Need an if to avoid resetting throttle when trying to set throttle
models.rover.setDefaultControls();
}
final resetSockets = !(const DeepCollectionEquality().equals(
models.settings.network.toJson(),
value.network.toJson(),
));
await models.settings.update(value);
await models.sockets.reset();
if (resetSockets && models.sockets.isEnabled) {
await models.sockets.reset();
}
models.video.reset();
isLoading = false;
notifyListeners();
Expand Down

0 comments on commit ee0ba06

Please sign in to comment.