Browse Source

neon: Refactor version checks

pull/325/head
jld3103 2 years ago
parent
commit
db8a9b095b
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 36
      packages/neon/neon/lib/src/pages/home.dart

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

@ -60,30 +60,22 @@ class _HomePageState extends State<HomePage> {
...appsResult.data!.map((final a) => a.id), ...appsResult.data!.map((final a) => a.id),
]) { ]) {
try { try {
bool? supported; final (supported, _) = switch (id) {
switch (id) { 'core' => await widget.account.client.core.isSupported(result.data),
case 'core': 'news' => await widget.account.client.news.isSupported(),
supported = await widget.account.client.core.isSupported(result.data); 'notes' => await widget.account.client.notes.isSupported(result.data),
break; _ => (true, null),
case 'news': };
supported = await widget.account.client.news.isSupported(); if (supported || !mounted) {
break; return;
case 'notes':
supported = await widget.account.client.notes.isSupported(result.data);
break;
} }
if (!(supported ?? true)) { var name = AppLocalizations.of(context).appImplementationName(id);
if (!mounted) { if (name == '') {
return; name = id;
}
var name = AppLocalizations.of(context).appImplementationName(id);
if (name == '') {
name = id;
}
await _showProblem(
AppLocalizations.of(context).errorUnsupportedVersion(name),
);
} }
await _showProblem(
AppLocalizations.of(context).errorUnsupportedVersion(name),
);
} catch (e, s) { } catch (e, s) {
debugPrint(e.toString()); debugPrint(e.toString());
debugPrint(s.toString()); debugPrint(s.toString());

Loading…
Cancel
Save