Timeline item sender profiles (#463)

* Adopt timeline item sender profiles for displaying user avatars and display names
* Prevent images from automatically being evicted from the in-memory cache when entering background
* Get rid of all the `urlString: String`s and start using proper URLs
* Add back manual display name loading as the sender profiles aren't working properly yet
* Implement a sender profile.
* Bump the RustSDK to v1.0.32-alpha

Co-authored-by: Doug <douglase@element.io>
This commit is contained in:
Stefan Ceriu
2023-01-18 16:29:44 +02:00
committed by GitHub
parent 8f906c7be7
commit 8f3f83167b
70 changed files with 390 additions and 495 deletions
@@ -158,12 +158,18 @@ class ClientProxy: ClientProxyProtocol {
}
}
}
func loadUserAvatarURLString() async -> Result<String, ClientProxyError> {
func loadUserAvatarURL() async -> Result<URL, ClientProxyError> {
await Task.dispatch(on: clientQueue) {
do {
let avatarURL = try self.client.avatarUrl()
return .success(avatarURL)
let urlString = try self.client.avatarUrl()
guard let url = URL(string: urlString) else {
MXLog.error("Invalid avatar URL string: \(String(describing: urlString))")
return .failure(.failedRetrievingAvatarURL)
}
return .success(url)
} catch {
return .failure(.failedRetrievingAvatarURL)
}
@@ -211,7 +217,7 @@ class ClientProxy: ClientProxyProtocol {
deviceDisplayName: String,
profileTag: String?,
lang: String,
url: String?,
url: URL?,
format: PushFormat?,
defaultPayload: [AnyHashable: Any]?) async throws {
// let defaultPayloadString = jsonString(from: defaultPayload)
@@ -312,11 +318,9 @@ class ClientProxy: ClientProxyProtocol {
let allRoomsViewProxy = SlidingSyncViewProxy(slidingSync: slidingSync, slidingSyncView: allRoomsView)
visibleRoomsSummaryProvider = RoomSummaryProvider(slidingSyncViewProxy: visibleRoomsViewProxy,
roomMessageFactory: RoomMessageFactory())
visibleRoomsSummaryProvider = RoomSummaryProvider(slidingSyncViewProxy: visibleRoomsViewProxy)
allRoomsSummaryProvider = RoomSummaryProvider(slidingSyncViewProxy: allRoomsViewProxy,
roomMessageFactory: RoomMessageFactory())
allRoomsSummaryProvider = RoomSummaryProvider(slidingSyncViewProxy: allRoomsViewProxy)
visibleRoomsViewProxy.visibleRangeUpdatePublisher.sink { [weak self] in
self?.restartSync()
@@ -390,8 +394,8 @@ class ClientProxy: ClientProxyProtocol {
}
extension ClientProxy: MediaProxyProtocol {
func mediaSourceForURLString(_ urlString: String) -> MediaSourceProxy {
mediaProxy.mediaSourceForURLString(urlString)
func mediaSourceForURL(_ url: URL) -> MediaSourceProxy {
mediaProxy.mediaSourceForURL(url)
}
func loadMediaContentForSource(_ source: MediaSourceProxy) async throws -> Data {