diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index b25e1977d..40ba16c50 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2786,5 +2786,7 @@ "placeholders": { "seconds": {} } - } + }, + "oneOfYourDevicesIsNotVerified": "One of your devices is not verified", + "noticeChatBackupDeviceVerification": "Note: When you connect all your devices to the chat backup, they are automatically verified." } diff --git a/lib/config/themes.dart b/lib/config/themes.dart index 4fcff7b75..3c06c06ee 100644 --- a/lib/config/themes.dart +++ b/lib/config/themes.dart @@ -130,6 +130,9 @@ abstract class FluffyThemes { borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2), ), ), + snackBarTheme: const SnackBarThemeData( + behavior: SnackBarBehavior.floating, + ), elevatedButtonTheme: ElevatedButtonThemeData( style: ElevatedButton.styleFrom( backgroundColor: colorScheme.secondaryContainer, diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 9fe479728..35447e716 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -820,6 +820,7 @@ class ChatListController extends State bool waitForFirstSync = false; Future _waitForFirstSync() async { + final router = GoRouter.of(context); final client = Matrix.of(context).client; await client.roomsLoading; await client.accountDataLoading; @@ -840,6 +841,33 @@ class ChatListController extends State setState(() { waitForFirstSync = true; }); + + if (client.userDeviceKeys[client.userID!]?.deviceKeys.values + .any((device) => !device.verified && !device.blocked) ?? + false) { + late final ScaffoldFeatureController controller; + final theme = Theme.of(context); + controller = ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + duration: const Duration(seconds: 15), + backgroundColor: theme.colorScheme.errorContainer, + content: Text( + L10n.of(context).oneOfYourDevicesIsNotVerified, + style: TextStyle( + color: theme.colorScheme.onErrorContainer, + ), + ), + action: SnackBarAction( + onPressed: () { + controller.close(); + router.go('/rooms/settings/devices'); + }, + textColor: theme.colorScheme.onErrorContainer, + label: L10n.of(context).settings, + ), + ), + ); + } } void cancelAction() { diff --git a/lib/pages/device_settings/device_settings.dart b/lib/pages/device_settings/device_settings.dart index daff3ad28..bb5293e0e 100644 --- a/lib/pages/device_settings/device_settings.dart +++ b/lib/pages/device_settings/device_settings.dart @@ -32,6 +32,28 @@ class DevicesSettingsController extends State { bool loadingDeletingDevices = false; String? errorDeletingDevices; + bool? chatBackupEnabled; + + @override + void initState() { + _checkChatBackup(); + super.initState(); + } + + void _checkChatBackup() async { + final client = Matrix.of(context).client; + if (client.encryption?.keyManager.enabled == true) { + if (await client.encryption?.keyManager.isCached() == false || + await client.encryption?.crossSigning.isCached() == false || + client.isUnknownSession && !mounted) { + setState(() { + chatBackupEnabled = false; + }); + return; + } + } + } + void removeDevicesAction(List devices) async { if (await showOkCancelAlertDialog( context: context, diff --git a/lib/pages/device_settings/device_settings_view.dart b/lib/pages/device_settings/device_settings_view.dart index 32a48b561..88d5c0476 100644 --- a/lib/pages/device_settings/device_settings_view.dart +++ b/lib/pages/device_settings/device_settings_view.dart @@ -48,6 +48,19 @@ class DevicesSettingsView extends StatelessWidget { return Column( mainAxisSize: MainAxisSize.min, children: [ + if (controller.chatBackupEnabled == false) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: ListTile( + leading: const CircleAvatar( + child: Icon(Icons.info_outlined), + ), + subtitle: Text( + L10n.of(context) + .noticeChatBackupDeviceVerification, + ), + ), + ), if (controller.thisDevice != null) ...[ Container( padding: const EdgeInsets.symmetric( diff --git a/lib/widgets/fluffy_chat_app.dart b/lib/widgets/fluffy_chat_app.dart index dfab1a6c3..661fb3362 100644 --- a/lib/widgets/fluffy_chat_app.dart +++ b/lib/widgets/fluffy_chat_app.dart @@ -34,7 +34,10 @@ class FluffyChatApp extends StatelessWidget { // Router must be outside of build method so that hot reload does not reset // the current path. - static final GoRouter router = GoRouter(routes: AppRoutes.routes); + static final GoRouter router = GoRouter( + routes: AppRoutes.routes, + debugLogDiagnostics: true, + ); @override Widget build(BuildContext context) {