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
This commit is contained in:
Mauro
2023-03-08 19:22:31 +01:00
committed by GitHub
parent e396d512dd
commit 8a21ae3c2e

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)")