Added user display names and switched to using an avatar url directly in the homeScreen viewModel for the current user.

This commit is contained in:
Stefan Ceriu
2022-03-21 19:35:24 +02:00
parent a9c0a8f334
commit d201ca1ad8
23 changed files with 152 additions and 71 deletions
@@ -21,22 +21,6 @@ struct MediaProvider: MediaProviderProtocol {
self.processingQueue = DispatchQueue(label: "MediaProviderProcessingQueue")
}
func loadCurrentUserAvatar(_ completion: @escaping (Result<UIImage?, MediaProviderError>) -> Void) {
processingQueue.async {
do {
let imageData = try client.avatar()
DispatchQueue.main.async {
completion(.success(UIImage(data: Data(bytes: imageData, count: imageData.count))))
}
} catch {
MXLog.error("Failed retrieving image with error: \(error)")
DispatchQueue.main.async {
completion(.failure(.failedRetrievingImage))
}
}
}
}
func imageForURL(_ url: String?) -> UIImage? {
guard let url = url else {
return nil
@@ -15,8 +15,6 @@ enum MediaProviderError: Error {
}
protocol MediaProviderProtocol {
func loadCurrentUserAvatar(_ completion: @escaping (Result<UIImage?, MediaProviderError>) -> Void)
func imageForURL(_ url: String?) -> UIImage?
func loadImageFromURL(_ url: String, _ completion: @escaping (Result<UIImage, MediaProviderError>) -> Void)