Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Display warning banner on unverified devices #1409

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
3 changes: 3 additions & 0 deletions lib/config/themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 28 additions & 0 deletions lib/pages/chat_list/chat_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ class ChatListController extends State<ChatList>
bool waitForFirstSync = false;

Future<void> _waitForFirstSync() async {
final router = GoRouter.of(context);
final client = Matrix.of(context).client;
await client.roomsLoading;
await client.accountDataLoading;
Expand All @@ -840,6 +841,33 @@ class ChatListController extends State<ChatList>
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() {
Expand Down
22 changes: 22 additions & 0 deletions lib/pages/device_settings/device_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ class DevicesSettingsController extends State<DevicesSettings> {
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<Device> devices) async {
if (await showOkCancelAlertDialog(
context: context,
Expand Down
13 changes: 13 additions & 0 deletions lib/pages/device_settings/device_settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion lib/widgets/fluffy_chat_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down