diff --git a/packages/neon/neon/lib/src/blocs/apps.dart b/packages/neon/neon/lib/src/blocs/apps.dart index 95312818..90acfe60 100644 --- a/packages/neon/neon/lib/src/blocs/apps.dart +++ b/packages/neon/neon/lib/src/blocs/apps.dart @@ -3,7 +3,7 @@ part of 'blocs.dart'; typedef NextcloudApp = NextcloudCoreNavigationApps_Ocs_Data; abstract class AppsBlocEvents { - void setActiveApp(final String? appID); + void setActiveApp(final String appID); } abstract class AppsBlocStates { @@ -13,7 +13,7 @@ abstract class AppsBlocStates { BehaviorSubject> get notificationsAppImplementation; - BehaviorSubject get activeAppID; + BehaviorSubject get activeAppID; BehaviorSubject get openNotifications; @@ -48,7 +48,7 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates } } if (!activeAppID.hasValue) { - await setActiveApp(initialApp); + await setActiveApp(initialApp!); } }), ); @@ -144,7 +144,7 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates } @override - BehaviorSubject activeAppID = BehaviorSubject(); + BehaviorSubject activeAppID = BehaviorSubject(); @override BehaviorSubject>>> appImplementations = @@ -175,15 +175,16 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates } @override - Future setActiveApp(final String? appID) async { - if (appID != null && - (await appImplementations.firstWhere((final a) => a.hasData)).requireData.tryFind(appID) != null) { + Future setActiveApp(final String appID) async { + final apps = await appImplementations.firstWhere((final a) => a.hasData); + if (apps.requireData.tryFind(appID) != null) { + // TODO: make activeAppID distinct if (activeAppID.valueOrNull != appID) { activeAppID.add(appID); } } else if (appID == 'notifications') { openNotifications.add(null); - } else if (appID != null) { + } else { throw Exception('App $appID not found'); } } diff --git a/packages/neon/neon/lib/src/pages/home.dart b/packages/neon/neon/lib/src/pages/home.dart index 74e648cc..42c16476 100644 --- a/packages/neon/neon/lib/src/pages/home.dart +++ b/packages/neon/neon/lib/src/pages/home.dart @@ -100,7 +100,7 @@ class _HomePageState extends State { @override Widget build(final BuildContext context) => ResultBuilder>.behaviorSubject( stream: _appsBloc.appImplementations, - builder: (final context, final appImplementations) => StreamBuilder( + builder: (final context, final appImplementations) => StreamBuilder( stream: _appsBloc.activeAppID, builder: (final context, final activeAppIDSnapshot) => OptionBuilder( option: _globalOptions.navigationMode, @@ -126,7 +126,7 @@ class _HomePageState extends State { ] else ...[ if (activeAppIDSnapshot.hasData) ...[ Expanded( - child: appImplementations.data!.find(activeAppIDSnapshot.data!).page, + child: appImplementations.requireData.find(activeAppIDSnapshot.requireData).page, ), ], ],