Browse Source

neon: Implement better extended version checking for apps

pull/62/head
jld3103 2 years ago
parent
commit
f90275d648
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 9
      packages/neon/lib/l10n/en.arb
  2. 12
      packages/neon/lib/l10n/localizations.dart
  3. 7
      packages/neon/lib/l10n/localizations_en.dart
  4. 2
      packages/neon/lib/src/blocs/apps.dart
  5. 73
      packages/neon/lib/src/pages/home/home.dart

9
packages/neon/lib/l10n/en.arb

@ -29,11 +29,11 @@
} }
} }
}, },
"errorUnsupportedNextcloudVersion": "Sorry this Nextcloud instance version is not supported. You need at least version {version} of Nextcloud.", "errorUnsupportedVersion": "Sorry, this Nextcloud {name} version is not supported.",
"@errorUnsupportedNextcloudVersion" : { "@errorUnsupportedVersion" : {
"placeholders": { "placeholders": {
"version": { "name": {
"type": "int" "type": "String"
} }
} }
}, },
@ -122,6 +122,7 @@
"accountOptionsInitialApp": "App to show initially", "accountOptionsInitialApp": "App to show initially",
"accountOptionsAutomatic": "Automatic", "accountOptionsAutomatic": "Automatic",
"licenses": "Licenses", "licenses": "Licenses",
"coreName": "Server",
"filesName": "Files", "filesName": "Files",
"filesUploadFiles": "Upload files", "filesUploadFiles": "Upload files",
"filesUploadImages": "Upload images", "filesUploadImages": "Upload images",

12
packages/neon/lib/l10n/localizations.dart

@ -179,11 +179,11 @@ abstract class AppLocalizations {
/// **'Permission for {name} is missing'** /// **'Permission for {name} is missing'**
String errorMissingPermission(String name); String errorMissingPermission(String name);
/// No description provided for @errorUnsupportedNextcloudVersion. /// No description provided for @errorUnsupportedVersion.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
/// **'Sorry this Nextcloud instance version is not supported. You need at least version {version} of Nextcloud.'** /// **'Sorry, this Nextcloud {name} version is not supported.'**
String errorUnsupportedNextcloudVersion(int version); String errorUnsupportedVersion(String name);
/// No description provided for @errorEmptyField. /// No description provided for @errorEmptyField.
/// ///
@ -533,6 +533,12 @@ abstract class AppLocalizations {
/// **'Licenses'** /// **'Licenses'**
String get licenses; String get licenses;
/// No description provided for @coreName.
///
/// In en, this message translates to:
/// **'Server'**
String get coreName;
/// No description provided for @filesName. /// No description provided for @filesName.
/// ///
/// In en, this message translates to: /// In en, this message translates to:

7
packages/neon/lib/l10n/localizations_en.dart

@ -57,8 +57,8 @@ class AppLocalizationsEn extends AppLocalizations {
} }
@override @override
String errorUnsupportedNextcloudVersion(int version) { String errorUnsupportedVersion(String name) {
return 'Sorry this Nextcloud instance version is not supported. You need at least version $version of Nextcloud.'; return 'Sorry, this Nextcloud $name version is not supported.';
} }
@override @override
@ -243,6 +243,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get licenses => 'Licenses'; String get licenses => 'Licenses';
@override
String get coreName => 'Server';
@override @override
String get filesName => 'Files'; String get filesName => 'Files';

2
packages/neon/lib/src/blocs/apps.dart

@ -54,7 +54,7 @@ class AppsBloc extends $AppsBloc {
); );
} else if (result is ResultCached && result.data != null) { } else if (result is ResultCached && result.data != null) {
_appImplementationsSubject.add( _appImplementationsSubject.add(
Result.success(_filteredAppImplementations((result as ResultCached<List<NextcloudApp>>).data)), ResultCached(_filteredAppImplementations((result as ResultCached<List<NextcloudApp>>).data)),
); );
} }

73
packages/neon/lib/src/pages/home/home.dart

@ -54,26 +54,43 @@ class _HomePageState extends State<HomePage> with tray.TrayListener, WindowListe
// ignore cached version and prevent duplicate dialogs // ignore cached version and prevent duplicate dialogs
if (result is ResultSuccess) { if (result is ResultSuccess) {
const requiredMajorVersion = 24; _appsBloc.appImplementations.listen((final appsResult) async {
if (result.data!.version!.major! < requiredMajorVersion) { // ignore cached version and prevent duplicate dialogs
await showDialog( if (appsResult is ResultSuccess) {
context: context, for (final id in [
builder: (final context) => AlertDialog( 'core',
title: Text(AppLocalizations.of(context).errorUnsupportedNextcloudVersion(requiredMajorVersion)), ...appsResult.data!.map((final a) => a.id),
actions: [ ]) {
ElevatedButton( try {
style: ElevatedButton.styleFrom( bool? supported;
backgroundColor: Colors.red, switch (id) {
), case 'core':
onPressed: () { supported = await widget.account.client.core.isSupported(result.data!);
Navigator.of(context).pop(); break;
}, case 'news':
child: Text(AppLocalizations.of(context).close), supported = await widget.account.client.news.isSupported();
), break;
], case 'notes':
), supported = await widget.account.client.notes.isSupported(result.data!);
break;
}
if (!(supported ?? true)) {
if (!mounted) {
return;
}
await _showUnsupportedVersion(
id == 'core'
? AppLocalizations.of(context).coreName
: appsResult.data!.singleWhere((final a) => a.id == id).name(context),
); );
} }
} catch (e, s) {
debugPrint(e.toString());
debugPrint(s.toString());
}
}
}
});
} }
} }
}); });
@ -259,6 +276,26 @@ class _HomePageState extends State<HomePage> with tray.TrayListener, WindowListe
} }
} }
Future _showUnsupportedVersion(final String appName) async {
await showDialog(
context: context,
builder: (final context) => AlertDialog(
title: Text(AppLocalizations.of(context).errorUnsupportedVersion(appName)),
actions: [
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
),
onPressed: () {
Navigator.of(context).pop();
},
child: Text(AppLocalizations.of(context).close),
),
],
),
);
}
@override @override
void dispose() { void dispose() {
_capabilitiesBloc.dispose(); _capabilitiesBloc.dispose();

Loading…
Cancel
Save