Commit e969d663 authored by Benoit Marty's avatar Benoit Marty
Browse files

Code review

parent 64f18349
......@@ -26,7 +26,7 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
* This class holds some data of a room.
* It can be retrieved by [org.matrix.android.sdk.api.session.room.Room] and [org.matrix.android.sdk.api.session.room.RoomService]
*/
data class RoomSummary constructor(
data class RoomSummary(
val roomId: String,
// Computed display name
val displayName: String = "",
......@@ -35,6 +35,7 @@ data class RoomSummary constructor(
val avatarUrl: String = "",
val canonicalAlias: String? = null,
val aliases: List<String> = emptyList(),
val joinRules: RoomJoinRules? = null,
val isDirect: Boolean = false,
val directUserId: String? = null,
val joinedMembersCount: Int? = 0,
......@@ -59,8 +60,7 @@ data class RoomSummary constructor(
val roomType: String? = null,
val spaceParents: List<SpaceParentInfo>? = null,
val spaceChildren: List<SpaceChildInfo>? = null,
val flattenParentIds: List<String> = emptyList(),
val joinRules: RoomJoinRules? = null
val flattenParentIds: List<String> = emptyList()
) {
val isVersioned: Boolean
......
......@@ -44,6 +44,7 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa
name = roomSummaryEntity.name ?: "",
topic = roomSummaryEntity.topic ?: "",
avatarUrl = roomSummaryEntity.avatarUrl ?: "",
joinRules = roomSummaryEntity.joinRules,
isDirect = roomSummaryEntity.isDirect,
directUserId = roomSummaryEntity.directUserId,
latestPreviewableEvent = latestEvent,
......@@ -91,8 +92,7 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa
parentRoomId = roomSummaryEntity.roomId
)
},
flattenParentIds = roomSummaryEntity.flattenParentIds?.split("|") ?: emptyList(),
joinRules = roomSummaryEntity.joinnRules
flattenParentIds = roomSummaryEntity.flattenParentIds?.split("|") ?: emptyList()
)
}
}
......@@ -21,6 +21,7 @@ import io.realm.RealmObject
import io.realm.annotations.Index
import io.realm.annotations.PrimaryKey
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.model.RoomJoinRules
import org.matrix.android.sdk.api.session.room.model.RoomSummary
......@@ -243,20 +244,16 @@ internal open class RoomSummaryEntity(
}
}
private var joinnRulesStr: String? = null
var joinnRules: RoomJoinRules?
private var joinRulesStr: String? = null
var joinRules: RoomJoinRules?
get() {
return joinnRulesStr?.let {
try {
RoomJoinRules.valueOf(it)
} catch (failure: Throwable) {
null
}
return joinRulesStr?.let {
tryOrNull { RoomJoinRules.valueOf(it) }
}
}
set(value) {
if (value?.name != joinnRulesStr) {
joinnRulesStr = value?.name
if (value?.name != joinRulesStr) {
joinRulesStr = value?.name
}
}
......
......@@ -132,6 +132,7 @@ internal class RoomSummaryUpdater @Inject constructor(
roomSummaryEntity.avatarUrl = roomAvatarResolver.resolve(realm, roomId)
roomSummaryEntity.name = ContentMapper.map(lastNameEvent?.content).toModel<RoomNameContent>()?.name
roomSummaryEntity.topic = ContentMapper.map(lastTopicEvent?.content).toModel<RoomTopicContent>()?.topic
roomSummaryEntity.joinRules = ContentMapper.map(joinRulesEvent?.content).toModel<RoomJoinRulesContent>()?.joinRules
roomSummaryEntity.latestPreviewableEvent = latestPreviewableEvent
roomSummaryEntity.canonicalAlias = ContentMapper.map(lastCanonicalAliasEvent?.content).toModel<RoomCanonicalAliasContent>()
?.canonicalAlias
......@@ -173,8 +174,6 @@ internal class RoomSummaryUpdater @Inject constructor(
crossSigningService.onUsersDeviceUpdate(otherRoomMembers)
}
}
roomSummaryEntity.joinnRules = ContentMapper.map(joinRulesEvent?.content).toModel<RoomJoinRulesContent>()?.joinRules
}
private fun RoomSummaryEntity.updateHasFailedSending() {
......
......@@ -123,8 +123,7 @@ internal class DefaultSpaceService @Inject constructor(
encryptionEventTs = null,
typingUsers = emptyList(),
isEncrypted = false,
flattenParentIds = emptyList(),
joinRules = null
flattenParentIds = emptyList()
),
second = response.rooms
?.filter { it.roomId != spaceId }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment