From 00a56a79305db61f8690fd595947ed329efd7e63 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Wed, 23 Dec 2020 10:25:38 +0100 Subject: [PATCH] fix: Don't re-render the lock icon nearly as often --- lib/components/encryption_button.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/components/encryption_button.dart b/lib/components/encryption_button.dart index c00937ac..b337a7dc 100644 --- a/lib/components/encryption_button.dart +++ b/lib/components/encryption_button.dart @@ -49,6 +49,8 @@ class _EncryptionButtonState extends State { await SimpleDialogs(context).tryRequestWithLoadingDialog( widget.room.enableEncryption(), ); + // we want to enable the lock icon + setState(() => null); } } @@ -60,11 +62,14 @@ class _EncryptionButtonState extends State { @override Widget build(BuildContext context) { - _onSyncSub ??= Matrix.of(context) - .client - .onSync - .stream - .listen((s) => setState(() => null)); + if (widget.room.encrypted) { + _onSyncSub ??= Matrix.of(context) + .client + .onSync + .stream + .where((s) => s.deviceLists != null) + .listen((s) => setState(() => null)); + } return FutureBuilder>( future: widget.room.encrypted ? widget.room.requestParticipants() : null,