Merge pull request #1409 from krille-chan/krille/unverified-banner

feat: Display warning banner on unverified devices
pull/1411/head
Krille-chan 5 months ago committed by GitHub
commit 38283d2b27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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."
}

@ -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,

@ -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;
@ -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() {

@ -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,

@ -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(

@ -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) {

Loading…
Cancel
Save