From 28dc8b4ff008f7b61192b57a7236283399711803 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 14 Jun 2021 08:30:27 +0200 Subject: [PATCH] refactor: Improve clearing This makes sure that the database is null after clearing so it will be built again using the databaseBuilder. Also this makes sure that the sync has aborted BEFORE the clearing starts to get rid of some warnings in the logs. --- lib/src/client.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/src/client.dart b/lib/src/client.dart index b2f56b12..379567ad 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -912,6 +912,7 @@ class Client extends MatrixApi { } await legacyDatabase.close(); if (migrateClient != null) { + _initLock = false; return init(); } } @@ -992,10 +993,15 @@ class Client extends MatrixApi { Future clear() async { Logs().outputEvents.clear(); try { + await abortSync(); await database?.clear(id); + _backgroundSync = true; } catch (e, s) { Logs().e('Unable to clear database', e, s); + } finally { + _database = null; } + _id = accessToken = syncFilterId = homeserver = _userID = _deviceID = _deviceName = prevBatch = null; _rooms = [];