diff --git a/packages/neon/lib/l10n/en.arb b/packages/neon/lib/l10n/en.arb index 708d0ad4..4688d2a5 100644 --- a/packages/neon/lib/l10n/en.arb +++ b/packages/neon/lib/l10n/en.arb @@ -29,6 +29,14 @@ } } }, + "errorUnsupportedNextcloudVersion": "Sorry this Nextcloud instance version is not supported. You need at least version {version} of Nextcloud.", + "@errorUnsupportedNextcloudVersion" : { + "placeholders": { + "version": { + "type": "int" + } + } + }, "validatorEmptyField": "This field can not be empty", "validatorInvalidURL": "Invalid URL provided", "delete": "Delete", diff --git a/packages/neon/lib/l10n/localizations.dart b/packages/neon/lib/l10n/localizations.dart index a4dfbd26..d517c72b 100644 --- a/packages/neon/lib/l10n/localizations.dart +++ b/packages/neon/lib/l10n/localizations.dart @@ -179,6 +179,12 @@ abstract class AppLocalizations { /// **'Permission for {name} is missing'** String errorMissingPermission(String name); + /// No description provided for @errorUnsupportedNextcloudVersion. + /// + /// In en, this message translates to: + /// **'Sorry this Nextcloud instance version is not supported. You need at least version {version} of Nextcloud.'** + String errorUnsupportedNextcloudVersion(int version); + /// No description provided for @validatorEmptyField. /// /// In en, this message translates to: diff --git a/packages/neon/lib/l10n/localizations_en.dart b/packages/neon/lib/l10n/localizations_en.dart index 93d8e0a4..b1885ce4 100644 --- a/packages/neon/lib/l10n/localizations_en.dart +++ b/packages/neon/lib/l10n/localizations_en.dart @@ -56,6 +56,11 @@ class AppLocalizationsEn extends AppLocalizations { return 'Permission for $name is missing'; } + @override + String errorUnsupportedNextcloudVersion(int version) { + return 'Sorry this Nextcloud instance version is not supported. You need at least version $version of Nextcloud.'; + } + @override String get validatorEmptyField => 'This field can not be empty'; diff --git a/packages/neon/lib/src/blocs/capabilities.dart b/packages/neon/lib/src/blocs/capabilities.dart index 72e5daec..7cd61b9e 100644 --- a/packages/neon/lib/src/blocs/capabilities.dart +++ b/packages/neon/lib/src/blocs/capabilities.dart @@ -6,7 +6,7 @@ import 'package:rxdart/rxdart.dart'; part 'capabilities.rxb.g.dart'; -typedef Capabilities = CoreServerCapabilitiesOcsDataCapabilities; +typedef Capabilities = CoreServerCapabilitiesOcsData; typedef NextcloudTheme = CoreServerCapabilitiesOcsDataCapabilitiesTheming; abstract class CapabilitiesBlocEvents {} @@ -26,12 +26,12 @@ class CapabilitiesBloc extends $CapabilitiesBloc { void _loadCapabilities() { _requestManager - .wrapNextcloud( + .wrapNextcloud( _client.id, _client.core, 'capabilities', () async => (await _client.core.getCapabilities())!, - (final response) => response.ocs!.data!.capabilities!, + (final response) => response.ocs!.data!, preloadCache: true, ) .listen(_capabilitiesSubject.add); diff --git a/packages/neon/lib/src/blocs/capabilities.rxb.g.dart b/packages/neon/lib/src/blocs/capabilities.rxb.g.dart index de7577c0..24e24dd1 100644 --- a/packages/neon/lib/src/blocs/capabilities.rxb.g.dart +++ b/packages/neon/lib/src/blocs/capabilities.rxb.g.dart @@ -20,13 +20,12 @@ abstract class $CapabilitiesBloc extends RxBlocBase final _compositeSubscription = CompositeSubscription(); /// The state of [capabilities] implemented in [_mapToCapabilitiesState] - late final BehaviorSubject> _capabilitiesState = - _mapToCapabilitiesState(); + late final BehaviorSubject> _capabilitiesState = _mapToCapabilitiesState(); @override - BehaviorSubject> get capabilities => _capabilitiesState; + BehaviorSubject> get capabilities => _capabilitiesState; - BehaviorSubject> _mapToCapabilitiesState(); + BehaviorSubject> _mapToCapabilitiesState(); @override CapabilitiesBlocEvents get events => this; diff --git a/packages/neon/lib/src/pages/home/home.dart b/packages/neon/lib/src/pages/home/home.dart index c77853ee..7bcc8200 100644 --- a/packages/neon/lib/src/pages/home/home.dart +++ b/packages/neon/lib/src/pages/home/home.dart @@ -50,7 +50,31 @@ class _HomePageState extends State with tray.TrayListener, WindowListe ); _capabilitiesBloc.capabilities.listen((final result) { if (result.data != null) { - widget.onThemeChanged(result.data!.theming!); + widget.onThemeChanged(result.data!.capabilities!.theming!); + + // ignore cached version and prevent duplicate dialogs + if (result is ResultSuccess) { + const requiredMajorVersion = 24; + if (result.data!.version!.major! < requiredMajorVersion) { + showDialog( + context: context, + builder: (final context) => AlertDialog( + title: Text(AppLocalizations.of(context).errorUnsupportedNextcloudVersion(requiredMajorVersion)), + actions: [ + ElevatedButton( + style: ElevatedButton.styleFrom( + primary: Colors.red, + ), + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text(AppLocalizations.of(context).close), + ), + ], + ), + ); + } + } } }); _appsBloc = AppsBloc( @@ -410,15 +434,15 @@ class _HomePageState extends State with tray.TrayListener, WindowListe children: [ if (capabilitiesData != null) ...[ Text( - capabilitiesData.theming!.name!, + capabilitiesData.capabilities!.theming!.name!, style: DefaultTextStyle.of(context).style.copyWith( color: Theme.of(context).colorScheme.onPrimary, ), ), - if (capabilitiesData.theming!.logo != null) ...[ + if (capabilitiesData.capabilities!.theming!.logo != null) ...[ Flexible( child: CachedURLImage( - url: capabilitiesData.theming!.logo!, + url: capabilitiesData.capabilities!.theming!.logo!, requestManager: _requestManager, client: widget.account.client, ),