Support a order key for accounts in config

This commit is contained in:
miruka
2020-05-14 03:33:34 -04:00
parent fd3fe06d15
commit 9b5b3a9f06
5 changed files with 38 additions and 17 deletions

View File

@@ -183,14 +183,19 @@ class Accounts(JSONDataFile):
"""
client = self.backend.clients[user_id]
saved = await self.read()
await self.write({
**await self.read(),
**saved,
client.user_id: {
"homeserver": client.homeserver,
"token": client.access_token,
"device_id": client.device_id,
"enabled": True,
"order": max(
account.get("order", i)
for i, account in enumerate(saved.values())
) + 1,
},
})