Use name instead of computed displayName
This commit is contained in:
parent
ff0b92272a
commit
da472ea858
@ -27,7 +27,9 @@ import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
||||
*/
|
||||
data class RoomSummary constructor(
|
||||
val roomId: String,
|
||||
// Computed display name
|
||||
val displayName: String = "",
|
||||
val name: String = "",
|
||||
val topic: String = "",
|
||||
val avatarUrl: String = "",
|
||||
val canonicalAlias: String? = null,
|
||||
|
@ -35,6 +35,7 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa
|
||||
return RoomSummary(
|
||||
roomId = roomSummaryEntity.roomId,
|
||||
displayName = roomSummaryEntity.displayName ?: "",
|
||||
name = roomSummaryEntity.name ?: "",
|
||||
topic = roomSummaryEntity.topic ?: "",
|
||||
avatarUrl = roomSummaryEntity.avatarUrl ?: "",
|
||||
isDirect = roomSummaryEntity.isDirect,
|
||||
|
@ -28,6 +28,7 @@ internal open class RoomSummaryEntity(
|
||||
@PrimaryKey var roomId: String = "",
|
||||
var displayName: String? = "",
|
||||
var avatarUrl: String? = "",
|
||||
var name: String? = "",
|
||||
var topic: String? = "",
|
||||
var latestPreviewableEvent: TimelineEventEntity? = null,
|
||||
var heroes: RealmList<String> = RealmList(),
|
||||
|
@ -23,6 +23,7 @@ import im.vector.matrix.android.api.session.events.model.toModel
|
||||
import im.vector.matrix.android.api.session.room.model.Membership
|
||||
import im.vector.matrix.android.api.session.room.model.RoomAliasesContent
|
||||
import im.vector.matrix.android.api.session.room.model.RoomCanonicalAliasContent
|
||||
import im.vector.matrix.android.api.session.room.model.RoomNameContent
|
||||
import im.vector.matrix.android.api.session.room.model.RoomTopicContent
|
||||
import im.vector.matrix.android.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM
|
||||
import im.vector.matrix.android.internal.crypto.crosssigning.SessionToCryptoRoomMembersUpdate
|
||||
@ -107,6 +108,7 @@ internal class RoomSummaryUpdater @Inject constructor(
|
||||
val latestPreviewableEvent = TimelineEventEntity.latestEvent(realm, roomId, includesSending = true,
|
||||
filterTypes = PREVIEWABLE_TYPES, filterContentRelation = true)
|
||||
|
||||
val lastNameEvent = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_NAME, stateKey = "")?.root
|
||||
val lastTopicEvent = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_TOPIC, stateKey = "")?.root
|
||||
val lastCanonicalAliasEvent = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_CANONICAL_ALIAS, stateKey = "")?.root
|
||||
val lastAliasesEvent = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_ALIASES, stateKey = "")?.root
|
||||
@ -122,6 +124,7 @@ internal class RoomSummaryUpdater @Inject constructor(
|
||||
|
||||
roomSummaryEntity.displayName = roomDisplayNameResolver.resolve(realm, roomId).toString()
|
||||
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.latestPreviewableEvent = latestPreviewableEvent
|
||||
roomSummaryEntity.canonicalAlias = ContentMapper.map(lastCanonicalAliasEvent?.content).toModel<RoomCanonicalAliasContent>()
|
||||
|
@ -72,7 +72,7 @@ class RoomSettingsViewModel @AssistedInject constructor(@Assisted initialState:
|
||||
val summary = asyncSummary()
|
||||
setState {
|
||||
copy(
|
||||
showSaveAction = summary?.displayName != newName
|
||||
showSaveAction = summary?.name != newName
|
||||
|| summary?.topic != newTopic
|
||||
|| summary?.canonicalAlias != newAlias
|
||||
|| newHistoryVisibility != null
|
||||
@ -89,7 +89,7 @@ class RoomSettingsViewModel @AssistedInject constructor(@Assisted initialState:
|
||||
copy(
|
||||
historyVisibilityEvent = room.getStateEvent(EventType.STATE_ROOM_HISTORY_VISIBILITY),
|
||||
roomSummary = async,
|
||||
newName = roomSummary?.displayName,
|
||||
newName = roomSummary?.name,
|
||||
newTopic = roomSummary?.topic,
|
||||
newCanonicalAlias = roomSummary?.canonicalAlias
|
||||
)
|
||||
@ -129,7 +129,7 @@ class RoomSettingsViewModel @AssistedInject constructor(@Assisted initialState:
|
||||
|
||||
val summary = state.roomSummary.invoke()
|
||||
|
||||
if (summary?.displayName != state.newName) {
|
||||
if (summary?.name != state.newName) {
|
||||
operationList.add(room.rx().updateName(state.newName ?: ""))
|
||||
}
|
||||
if (summary?.topic != state.newTopic) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user