diff --git a/CHANGELOG.md b/CHANGELOG.md index 706ef7ff..e4b14cfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,8 @@ and this project adheres to - Make sure the account shown in the left pane is immediatly updated after changing display name or avatar in the accounty settings +- When signing in a new account, correctly position it after the other + existing ones without needing a restart ## 0.5.0 diff --git a/TODO.md b/TODO.md index 32a95443..45182b46 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,6 @@ - fix cursor over field - update room highlight when creating new room - keyerror when forgetting room while loading members -- account order, and verify not adding to config fiel works ## Refactoring diff --git a/src/backend/backend.py b/src/backend/backend.py index 25d4f762..d0b1799c 100644 --- a/src/backend/backend.py +++ b/src/backend/backend.py @@ -117,7 +117,7 @@ class Backend: password: str, device_id: Optional[str] = None, homeserver: str = "https://matrix.org", - order: int = -1, + order: Optional[int] = None, ) -> str: """Create and register a `MatrixClient`, login and return a user ID.""" @@ -131,6 +131,14 @@ class Backend: await client.close() raise + if order is None and not self.models["accounts"]: + order = 0 + elif order is None: + order = max( + account.order + for i, account in enumerate(self.models["accounts"].values()) + ) + 1 + self.clients[client.user_id] = client self.models["accounts"][client.user_id] = Account(client.user_id,order) return client.user_id