Fix new added account's order

This commit is contained in:
miruka
2020-06-02 21:11:04 -04:00
parent 241c16932f
commit ccd2308427
3 changed files with 11 additions and 2 deletions

View File

@@ -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