fix: Bootstrap loop

This commit is contained in:
Krille Fear 2021-11-11 19:39:55 +01:00
parent 74f0469b83
commit 762139d43d
2 changed files with 31 additions and 16 deletions

View File

@ -77,7 +77,6 @@ class ChatListController extends State<ChatList> {
Matrix.of(context).client.rooms.where((r) => r.isSpace).toList(); Matrix.of(context).client.rooms.where((r) => r.isSpace).toList();
final selectedRoomIds = <String>{}; final selectedRoomIds = <String>{};
Future<bool> crossSigningCachedFuture;
bool crossSigningCached; bool crossSigningCached;
bool hideChatBackupBanner = false; bool hideChatBackupBanner = false;
@ -173,7 +172,9 @@ class ChatListController extends State<ChatList> {
void checkBootstrap() async { void checkBootstrap() async {
if (!Matrix.of(context).client.encryptionEnabled) return; if (!Matrix.of(context).client.encryptionEnabled) return;
final crossSigning = await crossSigningCachedFuture; final crossSigning =
await Matrix.of(context).client.encryption?.crossSigning?.isCached() ??
false;
final needsBootstrap = final needsBootstrap =
Matrix.of(context).client.encryption?.crossSigning?.enabled == false || Matrix.of(context).client.encryption?.crossSigning?.enabled == false ||
crossSigning == false; crossSigning == false;
@ -501,15 +502,6 @@ class ChatListController extends State<ChatList> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Matrix.of(context).navigatorContext = context; Matrix.of(context).navigatorContext = context;
crossSigningCachedFuture ??= Matrix.of(context)
.client
.encryption
?.crossSigning
?.isCached()
?.then((c) {
if (mounted) setState(() => crossSigningCached = c);
return c;
});
return ChatListView(this); return ChatListView(this);
} }
} }

View File

@ -59,11 +59,34 @@ class SettingsSecurityView extends StatelessWidget {
trailing: const Icon(Icons.vpn_key_outlined), trailing: const Icon(Icons.vpn_key_outlined),
), ),
ListTile( ListTile(
title: Text(L10n.of(context).cachedKeys), title: Text(L10n.of(context).crossSigningEnabled),
trailing: const Icon(Icons.wb_cloudy_outlined), trailing:
subtitle: Text( Matrix.of(context).client.encryption.crossSigning.enabled
'${Matrix.of(context).client.encryption.keyManager.enabled ? L10n.of(context).onlineKeyBackupEnabled : L10n.of(context).onlineKeyBackupDisabled}\n${Matrix.of(context).client.encryption.crossSigning.enabled ? L10n.of(context).crossSigningEnabled : L10n.of(context).crossSigningDisabled}'), ? const Icon(Icons.check, color: Colors.green)
onTap: controller.bootstrapSettingsAction, : const Icon(Icons.error, color: Colors.red),
),
ListTile(
title: Text(L10n.of(context).onlineKeyBackupEnabled),
trailing:
Matrix.of(context).client.encryption.keyManager.enabled
? const Icon(Icons.check, color: Colors.green)
: const Icon(Icons.error, color: Colors.red),
),
ListTile(
title: const Text('Session verified'),
trailing: !Matrix.of(context).client.isUnknownSession
? const Icon(Icons.check, color: Colors.green)
: const Icon(Icons.error, color: Colors.red),
),
FutureBuilder(
future:
Matrix.of(context).client.encryption.keyManager.isCached(),
builder: (context, snapshot) => ListTile(
title: Text(L10n.of(context).keysCached),
trailing: snapshot.data == true
? const Icon(Icons.check, color: Colors.green)
: const Icon(Icons.error, color: Colors.red),
),
), ),
}, },
], ],