From 8a21ae3c2e4624726fa7fbf203418f86e2620834 Mon Sep 17 00:00:00 2001 From: Mauro <34335419+Velin92@users.noreply.github.com> Date: Wed, 8 Mar 2023 19:22:31 +0100 Subject: [PATCH] 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 --- ElementX/Sources/Services/Client/ClientProxy.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 88c407bcc..ac17673d8 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -158,7 +158,6 @@ class ClientProxy: ClientProxyProtocol { func loadUserDisplayName() async -> Result { 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)")