mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
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:
@@ -42,7 +42,7 @@ class UserSessionStore: UserSessionStoreProtocol {
|
||||
keychainController.removeAllRestorationTokens()
|
||||
}
|
||||
|
||||
func restoreUserSession() async -> Result<UserSession, UserSessionStoreError> {
|
||||
func restoreUserSession() async -> Result<UserSessionProtocol, UserSessionStoreError> {
|
||||
let availableCredentials = keychainController.restorationTokens()
|
||||
|
||||
guard let credentials = availableCredentials.first else {
|
||||
@@ -51,11 +51,7 @@ class UserSessionStore: UserSessionStoreProtocol {
|
||||
|
||||
switch await restorePreviousLogin(credentials) {
|
||||
case .success(let clientProxy):
|
||||
return .success(UserSession(clientProxy: clientProxy,
|
||||
mediaProvider: MediaProvider(mediaProxy: clientProxy,
|
||||
imageCache: .onlyInMemory,
|
||||
fileCache: FileCache.default,
|
||||
backgroundTaskService: backgroundTaskService)))
|
||||
return .success(buildUserSessionWithClient(clientProxy))
|
||||
case .failure(let error):
|
||||
MXLog.error("Failed restoring login with error: \(error)")
|
||||
|
||||
@@ -67,14 +63,10 @@ class UserSessionStore: UserSessionStoreProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func userSession(for client: Client) async -> Result<UserSession, UserSessionStoreError> {
|
||||
func userSession(for client: Client) async -> Result<UserSessionProtocol, UserSessionStoreError> {
|
||||
switch await setupProxyForClient(client) {
|
||||
case .success(let clientProxy):
|
||||
return .success(UserSession(clientProxy: clientProxy,
|
||||
mediaProvider: MediaProvider(mediaProxy: clientProxy,
|
||||
imageCache: .onlyInMemory,
|
||||
fileCache: FileCache.default,
|
||||
backgroundTaskService: backgroundTaskService)))
|
||||
return .success(buildUserSessionWithClient(clientProxy))
|
||||
case .failure(let error):
|
||||
MXLog.error("Failed creating user session with error: \(error)")
|
||||
return .failure(error)
|
||||
@@ -99,6 +91,17 @@ class UserSessionStore: UserSessionStoreProtocol {
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func buildUserSessionWithClient(_ clientProxy: ClientProxyProtocol) -> UserSessionProtocol {
|
||||
let imageCache = ImageCache.onlyInMemory
|
||||
imageCache.memoryStorage.config.keepWhenEnteringBackground = true
|
||||
|
||||
return UserSession(clientProxy: clientProxy,
|
||||
mediaProvider: MediaProvider(mediaProxy: clientProxy,
|
||||
imageCache: imageCache,
|
||||
fileCache: FileCache.default,
|
||||
backgroundTaskService: backgroundTaskService))
|
||||
}
|
||||
|
||||
private func restorePreviousLogin(_ credentials: KeychainCredentials) async -> Result<ClientProxyProtocol, UserSessionStoreError> {
|
||||
let builder = ClientBuilder()
|
||||
.basePath(path: baseDirectory.path)
|
||||
|
||||
Reference in New Issue
Block a user