From e0e92152d0acf8bdc50209ce90d7b4cc975c38f7 Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 21 Aug 2020 05:29:42 -0400 Subject: [PATCH] Fix infinite account spinner when logging in twice --- TODO.md | 1 - src/backend/backend.py | 1 - src/backend/matrix_client.py | 2 +- src/backend/nio_callbacks.py | 6 +++--- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index 8c4aaca9..d6982d79 100644 --- a/TODO.md +++ b/TODO.md @@ -5,7 +5,6 @@ - refresh server list button - server list sorting method / explain what the % number is (stability) -- login with account already added → infinite spinner in room list - global presence control diff --git a/src/backend/backend.py b/src/backend/backend.py index be3c8ee5..fe4586d3 100644 --- a/src/backend/backend.py +++ b/src/backend/backend.py @@ -247,7 +247,6 @@ class Backend: await client.close() raise - # Check if the user is already present on mirage if client.user_id in self.clients: await client.logout() return client.user_id diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 22abe0a8..fce14613 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -281,7 +281,7 @@ class MatrixClient(nio.AsyncClient): self.user_id, Account(self.user_id, order), ) - # TODO: be abke to set presence before logging in + # TODO: be able to set presence before logging in item.set_fields(presence=Presence.State.online, connecting=True) self._presence = "online" self.start_task = asyncio.ensure_future(self._start()) diff --git a/src/backend/nio_callbacks.py b/src/backend/nio_callbacks.py index 22c0baf1..5492126b 100644 --- a/src/backend/nio_callbacks.py +++ b/src/backend/nio_callbacks.py @@ -113,13 +113,13 @@ class NioCallbacks: self.client.all_rooms[room_id], left=True, ) + account = self.models["accounts"][self.user_id] + account.connecting = False + if not self.client.first_sync_done.is_set(): self.client.first_sync_done.set() self.client.first_sync_date = datetime.now() - account = self.models["accounts"][self.user_id] - account.connecting = False - async def onKeysQueryResponse(self, resp: nio.KeysQueryResponse) -> None: refresh_rooms = {}