diff --git a/packages/neon/neon/lib/src/blocs/apps.dart b/packages/neon/neon/lib/src/blocs/apps.dart index b65a67a3..eccca553 100644 --- a/packages/neon/neon/lib/src/blocs/apps.dart +++ b/packages/neon/neon/lib/src/blocs/apps.dart @@ -44,7 +44,7 @@ abstract interface class AppsBlocStates { BehaviorSubject get openNotifications; /// A collection of unsupported apps and their minimum required version. - BehaviorSubject> get appVersions; + BehaviorSubject> get appVersionChecks; } /// The Bloc responsible for managing the [AppImplementation]s. @@ -131,12 +131,12 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates return; } - final notSupported = {}; + final notSupported = {}; try { - final coreCheck = _account.client.core.isSupported(capabilities.requireData); + final coreCheck = _account.client.core.getVersionCheck(capabilities.requireData); if (!coreCheck.isSupported) { - notSupported['core'] = coreCheck.minimumVersion.toString(); + notSupported['core'] = coreCheck; } } catch (e, s) { debugPrint(e.toString()); @@ -145,14 +145,14 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates for (final app in apps.requireData) { try { - final check = await app.isSupported(_account, capabilities.requireData); + final check = await app.getVersionCheck(_account, capabilities.requireData); if (check == null) { continue; } if (!check.isSupported) { - notSupported[app.id] = check.minimumVersion; + notSupported[app.id] = check; } } catch (e, s) { debugPrint(e.toString()); @@ -161,7 +161,7 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates } if (notSupported.isNotEmpty) { - appVersions.add(notSupported); + appVersionChecks.add(notSupported); } } @@ -190,7 +190,7 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates unawaited(notificationsAppImplementation.close()); unawaited(activeApp.close()); unawaited(openNotifications.close()); - unawaited(appVersions.close()); + unawaited(appVersionChecks.close()); super.dispose(); } @@ -209,7 +209,7 @@ class AppsBloc extends InteractiveBloc implements AppsBlocEvents, AppsBlocStates BehaviorSubject openNotifications = BehaviorSubject(); @override - BehaviorSubject> appVersions = BehaviorSubject(); + BehaviorSubject> appVersionChecks = BehaviorSubject(); @override Future refresh() async { diff --git a/packages/neon/neon/lib/src/models/app_implementation.dart b/packages/neon/neon/lib/src/models/app_implementation.dart index b70cffa1..f26bd21c 100644 --- a/packages/neon/neon/lib/src/models/app_implementation.dart +++ b/packages/neon/neon/lib/src/models/app_implementation.dart @@ -15,7 +15,7 @@ import 'package:neon/src/settings/models/storage.dart'; import 'package:neon/src/utils/provider.dart'; import 'package:neon/src/widgets/drawer_destination.dart'; import 'package:nextcloud/core.dart' as core; -import 'package:nextcloud/nextcloud.dart' show VersionSupported; +import 'package:nextcloud/nextcloud.dart' show VersionCheck; import 'package:provider/provider.dart'; import 'package:rxdart/rxdart.dart'; import 'package:vector_graphics/vector_graphics.dart'; @@ -61,7 +61,7 @@ abstract class AppImplementation /// A value of `null` means that it can not be known if the app is supported. /// This is the case for apps that depend on the server version like files and we assume that the app is supported. /// The server support is handled differently. - FutureOr?> isSupported( + FutureOr getVersionCheck( final Account account, final core.OcsGetCapabilitiesResponseApplicationJson_Ocs_Data capabilities, ) => diff --git a/packages/neon/neon/lib/src/pages/home.dart b/packages/neon/neon/lib/src/pages/home.dart index 04df3e20..3bfb360d 100644 --- a/packages/neon/neon/lib/src/pages/home.dart +++ b/packages/neon/neon/lib/src/pages/home.dart @@ -16,6 +16,7 @@ import 'package:neon/src/widgets/drawer.dart'; import 'package:neon/src/widgets/error.dart'; import 'package:neon/src/widgets/unified_search_results.dart'; import 'package:nextcloud/core.dart' as core; +import 'package:nextcloud/nextcloud.dart'; import 'package:provider/provider.dart'; /// The home page of Neon. @@ -35,7 +36,7 @@ class _HomePageState extends State { late global_options.GlobalOptions _globalOptions; late AccountsBloc _accountsBloc; late AppsBloc _appsBloc; - late StreamSubscription> _versionCheckSubscription; + late StreamSubscription> _versionCheckSubscription; @override void initState() { @@ -45,23 +46,19 @@ class _HomePageState extends State { _account = _accountsBloc.activeAccount.value!; _appsBloc = _accountsBloc.activeAppsBloc; - _versionCheckSubscription = _appsBloc.appVersions.listen((final values) { + _versionCheckSubscription = _appsBloc.appVersionChecks.listen((final values) { if (!mounted) { return; } final l10n = NeonLocalizations.of(context); - final buffer = StringBuffer()..writeln(); - for (final error in values.entries) { - final appId = error.key; - final minVersion = error.value; - final appName = l10n.appImplementationName(appId); + for (final entry in values.entries) { + final versionCheck = entry.value; + final appName = l10n.appImplementationName(entry.key); - if (appName.isNotEmpty && minVersion != null) { - buffer.writeln('- $appName $minVersion'); - } + buffer.writeln('- $appName >=${versionCheck.minimumVersion} <${versionCheck.maximumMajor + 1}.0.0'); } final message = l10n.errorUnsupportedAppVersions(buffer.toString()); diff --git a/packages/neon/neon/lib/src/pages/login_check_server_status.dart b/packages/neon/neon/lib/src/pages/login_check_server_status.dart index 042b024f..cdb99ed5 100644 --- a/packages/neon/neon/lib/src/pages/login_check_server_status.dart +++ b/packages/neon/neon/lib/src/pages/login_check_server_status.dart @@ -60,7 +60,8 @@ class _LoginCheckServerStatusPageState extends State child: ResultBuilder.behaviorSubject( subject: bloc.state, builder: (final context, final state) { - final success = state.hasData && state.requireData.isSupported && !state.requireData.maintenance; + final success = + state.hasData && state.requireData.versionCheck.isSupported && !state.requireData.maintenance; return Column( mainAxisAlignment: MainAxisAlignment.center, @@ -121,7 +122,7 @@ class _LoginCheckServerStatusPageState extends State ); } - if (result.requireData.isSupported) { + if (result.requireData.versionCheck.isSupported) { return NeonValidationTile( title: NeonLocalizations.of(context).loginSupportedServerVersion(result.requireData.versionstring), state: ValidationState.success, diff --git a/packages/neon/neon/pubspec.yaml b/packages/neon/neon/pubspec.yaml index 90e2b6a5..f6139ab9 100644 --- a/packages/neon/neon/pubspec.yaml +++ b/packages/neon/neon/pubspec.yaml @@ -56,6 +56,7 @@ dependencies: universal_io: ^2.0.0 url_launcher: ^6.1.0 vector_graphics: ^1.0.0 + version: ^3.0.0 window_manager: ^0.3.0 xml: ^6.0.0 diff --git a/packages/neon/neon_news/lib/neon_news.dart b/packages/neon/neon_news/lib/neon_news.dart index 53bb272a..f302834d 100644 --- a/packages/neon/neon_news/lib/neon_news.dart +++ b/packages/neon/neon_news/lib/neon_news.dart @@ -109,9 +109,9 @@ class NewsApp extends AppImplementation { BehaviorSubject getUnreadCounter(final NewsBloc bloc) => bloc.unreadCounter; @override - Future> isSupported( + Future getVersionCheck( final Account account, final core.OcsGetCapabilitiesResponseApplicationJson_Ocs_Data capabilities, ) => - account.client.news.isSupported(); + account.client.news.getVersionCheck(); } diff --git a/packages/neon/neon_notes/lib/neon_notes.dart b/packages/neon/neon_notes/lib/neon_notes.dart index 4ca927e8..3d5ccfce 100644 --- a/packages/neon/neon_notes/lib/neon_notes.dart +++ b/packages/neon/neon_notes/lib/neon_notes.dart @@ -95,11 +95,9 @@ class NotesApp extends AppImplementation { final RouteBase route = $notesAppRoute; @override - VersionSupported isSupported( + VersionCheck getVersionCheck( final Account account, final core.OcsGetCapabilitiesResponseApplicationJson_Ocs_Data capabilities, - ) { - final result = account.client.notes.isSupported(capabilities); - return (isSupported: result.isSupported, minimumVersion: result.minimumVersion.toString()); - } + ) => + account.client.notes.getVersionCheck(capabilities); }