Try to centralise session restoration through MatrixClientsHolder

This commit is contained in:
Jorge Martín 2023-07-17 15:05:13 +02:00
parent 0632d01d86
commit e2549a8308
5 changed files with 36 additions and 21 deletions

View file

@ -257,11 +257,11 @@ class DefaultNotificationDrawerManager @Inject constructor(
val currentUser = tryOrNull(
onError = { Timber.e(it, "Unable to retrieve info for user ${sessionId.value}") },
operation = {
val client = matrixClientsHolder.getOrNull(sessionId)
val client = matrixClientsHolder.requireSession(sessionId)
// myUserDisplayName cannot be empty else NotificationCompat.MessagingStyle() will crash
val myUserDisplayName = client?.loadUserDisplayName()?.getOrNull() ?: sessionId.value
val userAvatarUrl = client?.loadUserAvatarURLString()?.getOrNull()
val myUserDisplayName = client.loadUserDisplayName().getOrNull() ?: sessionId.value
val userAvatarUrl = client.loadUserAvatarURLString().getOrNull()
MatrixUser(
userId = sessionId,
displayName = myUserDisplayName,

View file

@ -68,7 +68,7 @@ class NotifiableEventResolver @Inject constructor(
suspend fun resolveEvent(sessionId: SessionId, roomId: RoomId, eventId: EventId): NotifiableEvent? {
// Restore session
val client = matrixClientsHolder.getOrNull(sessionId) ?: return null
val client = matrixClientsHolder.requireSession(sessionId)
val notificationService = client.notificationService()
val notificationData = notificationService.getNotification(
userId = sessionId,