Cached Avatar cancellation quick fix (#691)

* loading a cached avatar at first, and then actually doing the request so that the avatar can still be displayed without connection

* improved the code

* fix + changelog

* policy on how to fetch the avatar url added

* code improvements

* addressed al PR comments

* improved the error handling

* improved the async task code

* fixed a typo

* fixed another typo

* fix

* removed useless code
pull/692/head
Mauro 2023-03-08 19:22:31 +01:00 committed by GitHub
parent fb27efee10
commit 4144893e86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -158,7 +158,6 @@ class ClientProxy: ClientProxyProtocol {
func loadUserDisplayName() async -> Result<String, ClientProxyError> {
await Task.dispatch(on: clientQueue) {
do {
self.loadCachedAvatarURLTask?.cancel()
let displayName = try self.client.displayName()
return .success(displayName)
} catch {
@ -171,6 +170,7 @@ class ClientProxy: ClientProxyProtocol {
await Task.dispatch(on: clientQueue) {
do {
let urlString = try self.client.avatarUrl()
self.loadCachedAvatarURLTask?.cancel()
self.avatarURLSubject.value = urlString.flatMap(URL.init)
} catch {
MXLog.error("Failed fetching the user avatar url: \(error)")