feat: Display warning banner on unverified devices
This commit is contained in:
parent
f49a653c75
commit
d8acd92023
6 changed files with 73 additions and 2 deletions
|
|
@ -2786,5 +2786,7 @@
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"seconds": {}
|
"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),
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
snackBarTheme: const SnackBarThemeData(
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
),
|
||||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: colorScheme.secondaryContainer,
|
backgroundColor: colorScheme.secondaryContainer,
|
||||||
|
|
|
||||||
|
|
@ -820,6 +820,7 @@ class ChatListController extends State<ChatList>
|
||||||
bool waitForFirstSync = false;
|
bool waitForFirstSync = false;
|
||||||
|
|
||||||
Future<void> _waitForFirstSync() async {
|
Future<void> _waitForFirstSync() async {
|
||||||
|
final router = GoRouter.of(context);
|
||||||
final client = Matrix.of(context).client;
|
final client = Matrix.of(context).client;
|
||||||
await client.roomsLoading;
|
await client.roomsLoading;
|
||||||
await client.accountDataLoading;
|
await client.accountDataLoading;
|
||||||
|
|
@ -840,6 +841,33 @@ class ChatListController extends State<ChatList>
|
||||||
setState(() {
|
setState(() {
|
||||||
waitForFirstSync = true;
|
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() {
|
void cancelAction() {
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,28 @@ class DevicesSettingsController extends State<DevicesSettings> {
|
||||||
bool loadingDeletingDevices = false;
|
bool loadingDeletingDevices = false;
|
||||||
String? errorDeletingDevices;
|
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 {
|
void removeDevicesAction(List<Device> devices) async {
|
||||||
if (await showOkCancelAlertDialog(
|
if (await showOkCancelAlertDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,19 @@ class DevicesSettingsView extends StatelessWidget {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
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) ...[
|
if (controller.thisDevice != null) ...[
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
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
|
// Router must be outside of build method so that hot reload does not reset
|
||||||
// the current path.
|
// the current path.
|
||||||
static final GoRouter router = GoRouter(routes: AppRoutes.routes);
|
static final GoRouter router = GoRouter(
|
||||||
|
routes: AppRoutes.routes,
|
||||||
|
debugLogDiagnostics: true,
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue