Skip to content

Commit

Permalink
Default to home when section is not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
elibon99 committed Sep 11, 2024
1 parent bb00b2c commit f38e5a5
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 52 deletions.
38 changes: 0 additions & 38 deletions lib/app/views/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down Expand Up @@ -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),
Expand Down
11 changes: 3 additions & 8 deletions lib/desktop/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
1 change: 0 additions & 1 deletion lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 0 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 0 additions & 1 deletion lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 0 additions & 1 deletion lib/l10n/app_ja.arb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@
"app": {}
}
},
"s_app_disabled": "アプリケーションが無効です",
"l_app_disabled_desc": "アクセスするにはYubiKeyで{app}アプリケーションを有効にしてください",
"@l_app_disabled_desc": {
"placeholders": {
Expand Down
1 change: 0 additions & 1 deletion lib/l10n/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 0 additions & 1 deletion lib/l10n/app_vi.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit f38e5a5

Please sign in to comment.