Compare commits

...

1 Commits

Author SHA1 Message Date
Jonas Schäfer
ba18fe692f Fix ClientResponseError if a circle has a deleted user
Eventually, we need to clear that on the backend, but for now we
deal with it in the frontend.

Bonus: this also optimises the display of the circle by removing
O(n) backend requests.
2021-02-03 18:25:29 +01:00

View File

@@ -1,4 +1,3 @@
import asyncio
import json import json
import typing import typing
@@ -362,25 +361,21 @@ async def edit_circle(id_: str) -> typing.Union[str, quart.Response]:
return redirect(url_for(".circles")) return redirect(url_for(".circles"))
raise raise
circle_members = await asyncio.gather(*( users = sorted(
client.get_user_by_localpart( await client.list_users(),
localpart, key=lambda x: x.localpart
session=session, )
) circle_members = [
for localpart in sorted(circle.members) user for user in users
)) if user.localpart in circle.members
]
users = await client.list_users()
form = EditCircleForm() form = EditCircleForm()
form.user_to_add.choices = sorted( form.user_to_add.choices = [
( (user.localpart, user.localpart)
(u.localpart, u.localpart) for user in users
for u in users if user.localpart not in circle.members
if u.localpart not in circle.members ]
),
key=lambda x: x[1]
)
valid_users = [x[0] for x in form.user_to_add.choices] valid_users = [x[0] for x in form.user_to_add.choices]
invite_form = InvitePost() invite_form = InvitePost()