From 5863c8e168d796bcda3556409c46e27b71986862 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Sun, 6 Sep 2020 14:48:06 +0200 Subject: [PATCH] fix: Run advanced things in database handling in their own separate zone --- lib/encryption/encryption.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/encryption/encryption.dart b/lib/encryption/encryption.dart index 6b78c95..4b9e0fc 100644 --- a/lib/encryption/encryption.dart +++ b/lib/encryption/encryption.dart @@ -17,6 +17,7 @@ */ import 'dart:convert'; +import 'dart:async'; import 'package:pedantic/pedantic.dart'; @@ -81,16 +82,17 @@ class Encryption { if (['m.room_key_request', 'm.forwarded_room_key'].contains(event.type)) { // "just" room key request things. We don't need these asap, so we handle // them in the background - unawaited(keyManager.handleToDeviceEvent(event)); + unawaited(Zone.root.run(() => keyManager.handleToDeviceEvent(event))); } if (event.type.startsWith('m.key.verification.')) { // some key verification event. No need to handle it now, we can easily // do this in the background - unawaited(keyVerificationManager.handleToDeviceEvent(event)); + unawaited(Zone.root + .run(() => keyVerificationManager.handleToDeviceEvent(event))); } if (event.type.startsWith('m.secret.')) { // some ssss thing. We can do this in the background - unawaited(ssss.handleToDeviceEvent(event)); + unawaited(Zone.root.run(() => ssss.handleToDeviceEvent(event))); } } @@ -104,7 +106,8 @@ class Encryption { update.content['content']['msgtype'] .startsWith('m.key.verification.'))) { // "just" key verification, no need to do this in sync - unawaited(keyVerificationManager.handleEventUpdate(update)); + unawaited(Zone.root + .run(() => keyVerificationManager.handleEventUpdate(update))); } }