Default to home when section is not enabled

This commit is contained in:
Elias Bonnici 2024-09-11 15:53:16 +02:00
parent bb00b2c65e
commit f38e5a5f46
No known key found for this signature in database
GPG Key ID: 5EAC28EA3F980CCF
8 changed files with 3 additions and 52 deletions

View File

@ -27,16 +27,13 @@ import '../../fido/views/passkeys_screen.dart';
import '../../fido/views/webauthn_page.dart';
import '../../home/views/home_message_page.dart';
import '../../home/views/home_screen.dart';
import '../../management/views/management_screen.dart';
import '../../oath/views/oath_screen.dart';
import '../../oath/views/utils.dart';
import '../../otp/views/otp_screen.dart';
import '../../piv/views/piv_screen.dart';
import '../message.dart';
import '../models.dart';
import '../state.dart';
import 'device_error_screen.dart';
import 'message_page.dart';
class MainPage extends ConsumerWidget {
const MainPage({super.key});
@ -131,41 +128,6 @@ class MainPage extends ConsumerWidget {
return ref.watch(currentDeviceDataProvider).when(
data: (data) {
final section = ref.watch(currentSectionProvider);
final capabilities = section.capabilities;
if (section.getAvailability(data) == Availability.unsupported) {
return MessagePage(
title: section.getDisplayName(l10n),
capabilities: capabilities,
header: l10n.s_app_not_supported,
message: l10n.l_app_not_supported_on_yk(capabilities
.map((c) => c.getDisplayName(l10n))
.join(',')),
);
} else if (section.getAvailability(data) !=
Availability.enabled) {
return MessagePage(
title: section.getDisplayName(l10n),
capabilities: capabilities,
header: l10n.s_app_disabled,
message: l10n.l_app_disabled_desc(capabilities
.map((c) => c.getDisplayName(l10n))
.join(',')),
actionsBuilder: (context, expanded) => [
ActionChip(
label: Text(data.info.version.major > 4
? l10n.s_toggle_applications
: l10n.s_toggle_interfaces),
onPressed: () async {
await showBlurDialog(
context: context,
builder: (context) => ManagementScreen(data),
);
},
avatar: const Icon(Symbols.construction),
)
],
);
}
return switch (section) {
Section.home => HomeScreen(data),

View File

@ -261,15 +261,10 @@ class DesktopCurrentSectionNotifier extends CurrentSectionNotifier {
state.getAvailability(data) != Availability.enabled) {
state = Section.passkeys;
}
if (state.getAvailability(data) != Availability.unsupported) {
// Keep current app
return;
if (state.getAvailability(data) != Availability.enabled) {
// Default to home if app is not enabled
state = Section.home;
}
state = _supportedSections.firstWhere(
(app) => app.getAvailability(data) == Availability.enabled,
orElse: () => _supportedSections.first,
);
}
static Section _fromName(String? name, List<Section> supportedSections) =>

View File

@ -203,7 +203,6 @@
"app": {}
}
},
"s_app_disabled": "Anwendung deaktiviert",
"l_app_disabled_desc": "Aktivieren Sie die Anwendung '{app}' auf Ihrem YubiKey für Zugriff",
"@l_app_disabled_desc": {
"placeholders": {

View File

@ -203,7 +203,6 @@
"app": {}
}
},
"s_app_disabled": "Application disabled",
"l_app_disabled_desc": "Enable the '{app}' application on your YubiKey to access",
"@l_app_disabled_desc": {
"placeholders": {

View File

@ -203,7 +203,6 @@
"app": {}
}
},
"s_app_disabled": "Application désactivée",
"l_app_disabled_desc": "Activez l'application {app} sur votre YubiKey pour y accéder",
"@l_app_disabled_desc": {
"placeholders": {

View File

@ -203,7 +203,6 @@
"app": {}
}
},
"s_app_disabled": "アプリケーションが無効です",
"l_app_disabled_desc": "アクセスするにはYubiKeyで{app}アプリケーションを有効にしてください",
"@l_app_disabled_desc": {
"placeholders": {

View File

@ -203,7 +203,6 @@
"app": {}
}
},
"s_app_disabled": "Aplikacja została wyłączona",
"l_app_disabled_desc": "Włącz aplikację '{app}' w kluczu YubiKey, aby uzyskać do niej dostęp",
"@l_app_disabled_desc": {
"placeholders": {

View File

@ -203,7 +203,6 @@
"app": {}
}
},
"s_app_disabled": "Ứng dụng đã bị tắt",
"l_app_disabled_desc": "Bật ứng dụng '{app}' trên YubiKey của bạn để truy cập",
"@l_app_disabled_desc": {
"placeholders": {