Immediatly update cached profile after changing it

This commit is contained in:
miruka 2020-06-02 20:59:33 -04:00
parent 5bf1a90242
commit 241c16932f
5 changed files with 16 additions and 10 deletions

View File

@ -66,6 +66,9 @@ and this project adheres to
`ssl.SSLError: [SSL: KRB5_S_INIT] application data after close notify`
exceptions that occur in the Flatpak releases due to a Python 3.7 bug
- Make sure the account shown in the left pane is immediatly updated
after changing display name or avatar in the accounty settings
## 0.5.0

View File

@ -4,7 +4,6 @@
- update room highlight when creating new room
- keyerror when forgetting room while loading members
- account order, and verify not adding to config fiel works
- Refetch profile after manual profile change, don't wait for a room event
## Refactoring

View File

@ -229,11 +229,13 @@ class Backend:
# Client functions that don't need authentification
async def get_profile(self, user_id: str) -> nio.ProfileGetResponse:
async def get_profile(
self, user_id: str, use_cache: bool = True,
) -> nio.ProfileGetResponse:
"""Cache and return the matrix profile of `user_id`."""
async with self.get_profile_locks[user_id]:
if user_id in self.profile_cache:
if use_cache and user_id in self.profile_cache:
return self.profile_cache[user_id]
client = await self.get_any_client()

View File

@ -344,9 +344,7 @@ class MatrixClient(nio.AsyncClient):
async def update_own_profile(self) -> None:
"""Fetch our profile from server and Update our model `Account`."""
# XXX: verify this works when logging out quickly
resp = await self.backend.get_profile(self.user_id)
resp = await self.backend.get_profile(self.user_id, use_cache=False)
account = self.models["accounts"][self.user_id]
account.profile_updated = datetime.now()

View File

@ -13,9 +13,11 @@ HGridLayout {
py.callClientCoro(
userId, "set_displayname", [nameField.item.text], () => {
py.callClientCoro(userId, "update_own_profile", [], () => {
saveButton.nameChangeRunning = false
accountSettings.headerName =
Qt.binding(() => accountInfo.display_name)
})
}
)
}
@ -32,7 +34,9 @@ HGridLayout {
Qt.resolvedUrl(avatar.sourceOverride).replace(/^file:/, "")
py.callClientCoro(userId, "set_avatar_from_file", [path], () => {
py.callClientCoro(userId, "update_own_profile", [], () => {
saveButton.avatarChangeRunning = false
})
}, (errType, [httpCode]) => {
console.error("Avatar upload failed:", httpCode, errType)
saveButton.avatarChangeRunning = false