diff --git a/packages/neon/neon/lib/src/pages/home.dart b/packages/neon/neon/lib/src/pages/home.dart index b672184a..482f5608 100644 --- a/packages/neon/neon/lib/src/pages/home.dart +++ b/packages/neon/neon/lib/src/pages/home.dart @@ -4,12 +4,9 @@ const kQuickBarWidth = kAvatarSize + 20; class HomePage extends StatefulWidget { const HomePage({ - required this.account, super.key, }); - final Account account; - @override State createState() => _HomePageState(); } @@ -19,6 +16,7 @@ class _HomePageState extends State { final _scaffoldKey = GlobalKey(); final drawerScrollController = ScrollController(); + late Account _account; late GlobalOptions _globalOptions; late AccountsBloc _accountsBloc; late AppsBloc _appsBloc; @@ -27,11 +25,11 @@ class _HomePageState extends State { @override void initState() { super.initState(); - _globalOptions = Provider.of(context, listen: false); _accountsBloc = Provider.of(context, listen: false); - _appsBloc = _accountsBloc.getAppsBloc(widget.account); - _capabilitiesBloc = _accountsBloc.getCapabilitiesBloc(widget.account); + _account = _accountsBloc.activeAccount.value!; + _appsBloc = _accountsBloc.getAppsBloc(_account); + _capabilitiesBloc = _accountsBloc.getCapabilitiesBloc(_account); _appsBloc.openNotifications.listen((final _) async { final notificationsAppImplementation = _appsBloc.notificationsAppImplementation.valueOrNull; @@ -61,9 +59,9 @@ class _HomePageState extends State { ]) { try { final (supported, _) = switch (id) { - 'core' => await widget.account.client.core.isSupported(result.data), - 'news' => await widget.account.client.news.isSupported(), - 'notes' => await widget.account.client.notes.isSupported(result.data), + 'core' => await _account.client.core.isSupported(result.data), + 'news' => await _account.client.news.isSupported(), + 'notes' => await _account.client.notes.isSupported(result.data), _ => (true, null), }; if (supported || !mounted) { @@ -92,7 +90,7 @@ class _HomePageState extends State { Future _checkMaintenanceMode() async { try { - final status = await widget.account.client.core.getStatus(); + final status = await _account.client.core.getStatus(); if (status.maintenance) { if (!mounted) { return; @@ -207,7 +205,7 @@ class _HomePageState extends State { builder: (final context) { if (accountsSnapshot.hasData) { final accounts = accountsSnapshot.data!; - final account = accounts.find(widget.account.id)!; + final account = accounts.find(_account.id)!; final isQuickBar = navigationMode == NavigationMode.quickBar; final drawer = Drawer( @@ -303,7 +301,7 @@ class _HomePageState extends State { dropdownColor: Theme.of(context).colorScheme.primary, iconEnabledColor: Theme.of(context).colorScheme.onBackground, - value: widget.account.id, + value: _account.id, items: accounts .map>( (final account) => DropdownMenuItem( diff --git a/packages/neon/neon/lib/src/router.dart b/packages/neon/neon/lib/src/router.dart index a7f206a7..12935224 100644 --- a/packages/neon/neon/lib/src/router.dart +++ b/packages/neon/neon/lib/src/router.dart @@ -33,7 +33,6 @@ class AppRouter extends RouterDelegate with ChangeNotifier, PopNavigato name: 'home', child: HomePage( key: Key(currentConfiguration!.id), - account: currentConfiguration!, ), ), ],