mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Set DirectMessagesContent immutable
This commit is contained in:
parent
a399747bb4
commit
0a08746937
3 changed files with 14 additions and 3 deletions
|
@ -17,6 +17,7 @@
|
|||
package org.matrix.android.sdk.internal.session.sync
|
||||
|
||||
import org.matrix.android.sdk.api.MatrixPatterns
|
||||
import org.matrix.android.sdk.internal.session.sync.model.accountdata.toMutable
|
||||
import org.matrix.android.sdk.internal.session.user.accountdata.DirectChatsHelper
|
||||
import org.matrix.android.sdk.internal.session.user.accountdata.UpdateUserAccountDataTask
|
||||
import javax.inject.Inject
|
||||
|
@ -38,7 +39,7 @@ internal class SyncResponsePostTreatmentAggregatorHandler @Inject constructor(
|
|||
}
|
||||
|
||||
private suspend fun updateDirectUserIds(directUserIdsToUpdate: Map<String, String>) {
|
||||
val directChats = directChatsHelper.getLocalDirectMessages()
|
||||
val directChats = directChatsHelper.getLocalDirectMessages().toMutable()
|
||||
var hasUpdate = false
|
||||
directUserIdsToUpdate.forEach { (roomId, candidateUserId) ->
|
||||
// consider room is a DM if referenced in the DM dictionary
|
||||
|
|
|
@ -53,6 +53,7 @@ import org.matrix.android.sdk.internal.session.sync.model.accountdata.Breadcrumb
|
|||
import org.matrix.android.sdk.internal.session.sync.model.accountdata.DirectMessagesContent
|
||||
import org.matrix.android.sdk.internal.session.sync.model.accountdata.IgnoredUsersContent
|
||||
import org.matrix.android.sdk.internal.session.sync.model.accountdata.UserAccountDataSync
|
||||
import org.matrix.android.sdk.internal.session.sync.model.accountdata.toMutable
|
||||
import org.matrix.android.sdk.internal.session.user.accountdata.DirectChatsHelper
|
||||
import org.matrix.android.sdk.internal.session.user.accountdata.UpdateUserAccountDataTask
|
||||
import timber.log.Timber
|
||||
|
@ -83,7 +84,7 @@ internal class UserAccountDataSyncHandler @Inject constructor(
|
|||
// If we get some direct chat invites, we synchronize the user account data including those.
|
||||
suspend fun synchronizeWithServerIfNeeded(invites: Map<String, InvitedRoomSync>) {
|
||||
if (invites.isNullOrEmpty()) return
|
||||
val directChats = directChatsHelper.getLocalDirectMessages()
|
||||
val directChats = directChatsHelper.getLocalDirectMessages().toMutable()
|
||||
var hasUpdate = false
|
||||
monarchy.doWithRealm { realm ->
|
||||
invites.forEach { (roomId, _) ->
|
||||
|
|
|
@ -19,4 +19,13 @@ package org.matrix.android.sdk.internal.session.sync.model.accountdata
|
|||
/**
|
||||
* Keys are userIds, values are list of roomIds
|
||||
*/
|
||||
internal typealias DirectMessagesContent = MutableMap<String, MutableList<String>>
|
||||
internal typealias DirectMessagesContent = Map<String, List<String>>
|
||||
|
||||
/**
|
||||
* Returns a new [MutableMap] with all elements of this collection.
|
||||
*/
|
||||
internal fun DirectMessagesContent.toMutable(): MutableMap<String, MutableList<String>> {
|
||||
return map { it.key to it.value.toMutableList() }
|
||||
.toMap()
|
||||
.toMutableMap()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue