Cleanup and avoid duplicate

This commit is contained in:
Benoit Marty 2020-11-23 17:59:25 +01:00 committed by Benoit Marty
parent 893ebd9690
commit ed4676bb6c
3 changed files with 15 additions and 11 deletions

View File

@ -111,7 +111,7 @@ internal class DefaultStateService @AssistedInject constructor(@Assisted private
eventType = EventType.STATE_ROOM_CANONICAL_ALIAS,
body = RoomCanonicalAliasContent(
canonicalAlias = alias,
alternativeAliases = altAliases
alternativeAliases = altAliases.distinct()
).toContent(),
callback = callback,
stateKey = null

View File

@ -155,8 +155,7 @@ class RoomAliasViewModel @AssistedInject constructor(@Assisted initialState: Roo
private fun handleSetNewAlias(action: RoomAliasAction.SetNewAlias) {
setState {
copy(
newAlias = action.aliasLocalPart,
asyncNewAliasRequest = Uninitialized
newAlias = action.aliasLocalPart
)
}
}
@ -195,7 +194,12 @@ class RoomAliasViewModel @AssistedInject constructor(@Assisted initialState: Roo
postLoading(true)
room.updateCanonicalAlias(canonicalAlias, alternativeAliases, object : MatrixCallback<Unit> {
override fun onSuccess(data: Unit) {
postLoading(false)
setState {
copy(
isLoading = false,
newAlias = ""
)
}
}
override fun onFailure(failure: Throwable) {
@ -228,6 +232,7 @@ class RoomAliasViewModel @AssistedInject constructor(@Assisted initialState: Roo
setState {
copy(
isLoading = false,
newLocalAlias = "",
asyncNewLocalAliasRequest = Uninitialized
)
}

View File

@ -31,7 +31,6 @@ data class RoomAliasViewState(
val canonicalAlias: String? = null,
val alternativeAliases: List<String> = emptyList(),
val newAlias: String = "",
val asyncNewAliasRequest: Async<Unit> = Uninitialized,
val localAliases: Async<List<String>> = Uninitialized,
val newLocalAlias: String = "",
val asyncNewLocalAliasRequest: Async<Unit> = Uninitialized