mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 19:44:05 +00:00
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:
@@ -158,7 +158,6 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
func loadUserDisplayName() async -> Result<String, ClientProxyError> {
|
func loadUserDisplayName() async -> Result<String, ClientProxyError> {
|
||||||
await Task.dispatch(on: clientQueue) {
|
await Task.dispatch(on: clientQueue) {
|
||||||
do {
|
do {
|
||||||
self.loadCachedAvatarURLTask?.cancel()
|
|
||||||
let displayName = try self.client.displayName()
|
let displayName = try self.client.displayName()
|
||||||
return .success(displayName)
|
return .success(displayName)
|
||||||
} catch {
|
} catch {
|
||||||
@@ -171,6 +170,7 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
await Task.dispatch(on: clientQueue) {
|
await Task.dispatch(on: clientQueue) {
|
||||||
do {
|
do {
|
||||||
let urlString = try self.client.avatarUrl()
|
let urlString = try self.client.avatarUrl()
|
||||||
|
self.loadCachedAvatarURLTask?.cancel()
|
||||||
self.avatarURLSubject.value = urlString.flatMap(URL.init)
|
self.avatarURLSubject.value = urlString.flatMap(URL.init)
|
||||||
} catch {
|
} catch {
|
||||||
MXLog.error("Failed fetching the user avatar url: \(error)")
|
MXLog.error("Failed fetching the user avatar url: \(error)")
|
||||||
|
|||||||
Reference in New Issue
Block a user