mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-29 17:21:45 +01:00
fix(home): Local control is a fallback, not proof the app is connected
The app link read connectedTrainerConnections, which includes Local. Local reports connected the moment it is switched on — it types into whatever window happens to be in front — so it says nothing about whether the trainer app is reachable. With a network method also enabled (the default for MyWhoosh) that painted the link green while the connection the rider actually rides on sat unactivated, hiding the one thing left to do. The link now reads non-local connections whenever any non-local method is enabled, and all of them when Local is all there is — because then Local IS the answer. The summary uses the same list, so the card cannot caption itself "Local" while the network method is down. The rule already existed: InactivityDisconnector draws exactly this distinction, and connectedNonLocalTrainerConnections was already there for it. The home chain simply was not using it. So the getter lives in core.logic beside its siblings rather than as a private method on the page — the next screen that needs it should find it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -294,9 +294,9 @@ class _HomePageState extends State<HomePage> {
|
||||
name: trainerApp?.name,
|
||||
selfHosted: trainerApp is BikeControl,
|
||||
hasEnabledConnection: core.logic.enabledTrainerConnections.isNotEmpty,
|
||||
isConnected: core.logic.connectedTrainerConnections.isNotEmpty,
|
||||
isConnected: core.logic.appFacingConnections.isNotEmpty,
|
||||
wasConnectedThisSession: _appConnectedThisSession,
|
||||
connectionSummary: core.logic.connectedTrainerConnections.firstOrNull?.title,
|
||||
connectionSummary: core.logic.appFacingConnections.firstOrNull?.title,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -411,6 +411,23 @@ class CoreLogic {
|
||||
return null;
|
||||
}
|
||||
|
||||
/// The connections that count as "the trainer app is receiving commands".
|
||||
///
|
||||
/// Local control is a fallback, not an answer: it types into whatever window
|
||||
/// happens to be in front, so it reports connected the moment it is switched
|
||||
/// on and says nothing about whether the trainer app is reachable. With a
|
||||
/// network method also enabled — the default for MyWhoosh — counting Local
|
||||
/// would call the app connected while the method the rider actually rides on
|
||||
/// sat unactivated.
|
||||
///
|
||||
/// When Local is all there is, it IS the answer and counts. Same distinction
|
||||
/// [InactivityDisconnector] draws between `isTrainerAppConnected` and
|
||||
/// `isOnlyLocalActive`.
|
||||
List<TrainerConnection> get appFacingConnections {
|
||||
final onlyLocal = enabledNonLocalTrainerConnections.isEmpty && core.settings.getLocalEnabled();
|
||||
return onlyLocal ? connectedTrainerConnections : connectedNonLocalTrainerConnections;
|
||||
}
|
||||
|
||||
List<TrainerConnection> get enabledNonLocalTrainerConnections => [
|
||||
if (isObpBleEnabled) core.obpBluetoothEmulator,
|
||||
if (isObpMdnsEnabled) core.obpMdnsEmulator,
|
||||
|
||||
Reference in New Issue
Block a user