Correctly handle account with invalid access token

Show a popup saying the session was signed out and cleanup
the models data, instead of spamming the users with
never-ending errors.
This commit is contained in:
miruka
2020-09-04 11:21:36 -04:00
parent 3c9895b0b2
commit 7b6478f514
9 changed files with 92 additions and 9 deletions

View File

@@ -18,7 +18,7 @@ from appdirs import AppDirs
import nio
from . import __app_name__
from .errors import MatrixError
from .errors import MatrixError, MatrixInvalidAccessToken
from .matrix_client import MatrixClient
from .media_cache import MediaCache
from .models import SyncId
@@ -305,6 +305,11 @@ class Backend:
client = self.clients.pop(user_id, None)
if client:
try:
await client.logout()
except MatrixInvalidAccessToken:
pass
self.models["accounts"].pop(user_id, None)
self.models["matching_accounts"].pop(user_id, None)
self.models[user_id, "uploads"].clear()
@@ -317,8 +322,6 @@ class Backend:
self.models[user_id, "rooms"].clear()
await client.logout()
await self.saved_accounts.delete(user_id)