diff --git a/packages/neon/lib/src/neon.dart b/packages/neon/lib/src/neon.dart index cf003cb1..3ec595c1 100644 --- a/packages/neon/lib/src/neon.dart +++ b/packages/neon/lib/src/neon.dart @@ -57,7 +57,6 @@ import 'package:xdg_directories/xdg_directories.dart' as xdg; part 'app.dart'; part 'pages/home/home.dart'; -part 'pages/home/widgets/server_status.dart'; part 'pages/login/login.dart'; part 'pages/settings/account_specific_settings.dart'; part 'pages/settings/nextcloud_app_specific_settings.dart'; diff --git a/packages/neon/lib/src/pages/home/home.dart b/packages/neon/lib/src/pages/home/home.dart index f655b1ad..807963d4 100644 --- a/packages/neon/lib/src/pages/home/home.dart +++ b/packages/neon/lib/src/pages/home/home.dart @@ -65,10 +65,12 @@ class _HomePageState extends State { if (!mounted) { return; } - await _showUnsupportedVersion( - id == 'core' - ? AppLocalizations.of(context).coreName - : appsResult.data!.singleWhere((final a) => a.id == id).name(context), + await _showProblem( + AppLocalizations.of(context).errorUnsupportedVersion( + id == 'core' + ? AppLocalizations.of(context).coreName + : appsResult.data!.singleWhere((final a) => a.id == id).name(context), + ), ); } } catch (e, s) { @@ -81,13 +83,32 @@ class _HomePageState extends State { } } }); + + unawaited(_checkMaintenanceMode()); + } + + Future _checkMaintenanceMode() async { + try { + final status = await widget.account.client.core.getStatus(); + if (status.maintenance) { + if (!mounted) { + return; + } + await _showProblem( + AppLocalizations.of(context).errorServerInMaintenanceMode, + ); + } + } catch (e) { + debugPrint(e.toString()); + ExceptionWidget.showSnackbar(context, e); + } } - Future _showUnsupportedVersion(final String appName) async { + Future _showProblem(final String title) async { await showDialog( context: context, builder: (final context) => AlertDialog( - title: Text(AppLocalizations.of(context).errorUnsupportedVersion(appName)), + title: Text(title), actions: [ ElevatedButton( style: ElevatedButton.styleFrom( @@ -508,9 +529,6 @@ class _HomePageState extends State { Expanded( child: Column( children: [ - ServerStatus( - account: widget.account, - ), ExceptionWidget( appsError, onRetry: () { diff --git a/packages/neon/lib/src/pages/home/widgets/server_status.dart b/packages/neon/lib/src/pages/home/widgets/server_status.dart deleted file mode 100644 index 1d454ef4..00000000 --- a/packages/neon/lib/src/pages/home/widgets/server_status.dart +++ /dev/null @@ -1,35 +0,0 @@ -part of '../../../neon.dart'; - -class ServerStatus extends StatefulWidget { - const ServerStatus({ - required this.account, - super.key, - }); - - final Account account; - - @override - State createState() => _ServerStatusState(); -} - -class _ServerStatusState extends State { - @override - void initState() { - super.initState(); - - WidgetsBinding.instance.addPostFrameCallback((final _) async { - try { - final status = await widget.account.client.core.getStatus(); - if (status.maintenance && mounted) { - ExceptionWidget.showSnackbar(context, AppLocalizations.of(context).errorServerInMaintenanceMode); - } - } catch (e) { - debugPrint(e.toString()); - ExceptionWidget.showSnackbar(context, e); - } - }); - } - - @override - Widget build(final BuildContext context) => Container(); -}