mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Small cleanup, handle case of no local alias, handle unpublish of canonical alias
This commit is contained in:
parent
6c7eb6ea8c
commit
50ddd3cf31
4 changed files with 17 additions and 8 deletions
|
@ -320,7 +320,8 @@ internal interface RoomAPI {
|
|||
@Body body: ReportContentBody): Call<Unit>
|
||||
|
||||
/**
|
||||
* Get local aliases of this room
|
||||
* Get a list of aliases maintained by the local server for the given room.
|
||||
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-aliases
|
||||
*/
|
||||
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "org.matrix.msc2432/rooms/{roomId}/aliases")
|
||||
fun getAliases(@Path("roomId") roomId: String): Call<GetAliasesResponse>
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.squareup.moshi.JsonClass
|
|||
@JsonClass(generateAdapter = true)
|
||||
internal data class GetAliasesResponse(
|
||||
/**
|
||||
* The list of aliases currently defined on the local server for the given room
|
||||
* Required. The server's local aliases on the room. Can be empty.
|
||||
*/
|
||||
@Json(name = "aliases") val aliases: List<String> = emptyList()
|
||||
)
|
||||
|
|
|
@ -199,11 +199,18 @@ class RoomAliasController @Inject constructor(
|
|||
}
|
||||
}
|
||||
is Success -> {
|
||||
localAliases().forEachIndexed { idx, localAlias ->
|
||||
profileActionItem {
|
||||
id("loc_$idx")
|
||||
title(localAlias)
|
||||
listener { callback?.openAliasDetail(localAlias) }
|
||||
if (localAliases().isEmpty()) {
|
||||
settingsInfoItem {
|
||||
id("locEmpty")
|
||||
helperTextResId(R.string.room_alias_local_address_empty)
|
||||
}
|
||||
} else {
|
||||
localAliases().forEachIndexed { idx, localAlias ->
|
||||
profileActionItem {
|
||||
id("loc_$idx")
|
||||
title(localAlias)
|
||||
listener { callback?.openAliasDetail(localAlias) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,7 +283,8 @@ class RoomAliasViewModel @AssistedInject constructor(@Assisted initialState: Roo
|
|||
|
||||
private fun handleUnpublishAlias(action: RoomAliasAction.UnpublishAlias) = withState { state ->
|
||||
updateCanonicalAlias(
|
||||
canonicalAlias = state.canonicalAlias,
|
||||
// We can also unpublish the canonical alias
|
||||
canonicalAlias = state.canonicalAlias.takeIf { it != action.alias },
|
||||
alternativeAliases = state.alternativeAliases - action.alias,
|
||||
closeForm = false
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue