Skip to content

Commit

Permalink
Do not allow starting site if there are errors
Browse files Browse the repository at this point in the history
  • Loading branch information
IanVS committed Jan 16, 2025
1 parent 9918376 commit 8694f48
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/screens/SiteDetailScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ class _SiteDetailScreenState extends State<SiteDetailScreen> {
}

Widget _buildConfig() {
void handleChange(v) async {
try {
if (v) {
await widget.site.start();
} else {
await widget.site.stop();
}
} catch (error) {
var action = v ? 'start' : 'stop';
Utils.popError(context, 'Failed to $action the site', error.toString());
}
}

return ConfigSection(children: <Widget>[
ConfigItem(
label: Text('Status'),
Expand All @@ -145,18 +158,7 @@ class _SiteDetailScreenState extends State<SiteDetailScreen> {
Switch.adaptive(
value: widget.site.connected,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onChanged: (v) async {
try {
if (v) {
await widget.site.start();
} else {
await widget.site.stop();
}
} catch (error) {
var action = v ? 'start' : 'stop';
Utils.popError(context, 'Failed to $action the site', error.toString());
}
},
onChanged: widget.site.errors.length > 0 && !widget.site.connected ? null : handleChange,
)
])),
ConfigPageItem(
Expand Down

0 comments on commit 8694f48

Please sign in to comment.