mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +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>
|
@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")
|
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "org.matrix.msc2432/rooms/{roomId}/aliases")
|
||||||
fun getAliases(@Path("roomId") roomId: String): Call<GetAliasesResponse>
|
fun getAliases(@Path("roomId") roomId: String): Call<GetAliasesResponse>
|
||||||
|
|
|
@ -22,7 +22,7 @@ import com.squareup.moshi.JsonClass
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class GetAliasesResponse(
|
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()
|
@Json(name = "aliases") val aliases: List<String> = emptyList()
|
||||||
)
|
)
|
||||||
|
|
|
@ -199,6 +199,12 @@ class RoomAliasController @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is Success -> {
|
is Success -> {
|
||||||
|
if (localAliases().isEmpty()) {
|
||||||
|
settingsInfoItem {
|
||||||
|
id("locEmpty")
|
||||||
|
helperTextResId(R.string.room_alias_local_address_empty)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
localAliases().forEachIndexed { idx, localAlias ->
|
localAliases().forEachIndexed { idx, localAlias ->
|
||||||
profileActionItem {
|
profileActionItem {
|
||||||
id("loc_$idx")
|
id("loc_$idx")
|
||||||
|
@ -207,6 +213,7 @@ class RoomAliasController @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
is Fail -> {
|
is Fail -> {
|
||||||
errorWithRetryItem {
|
errorWithRetryItem {
|
||||||
id("alt_error")
|
id("alt_error")
|
||||||
|
|
|
@ -283,7 +283,8 @@ class RoomAliasViewModel @AssistedInject constructor(@Assisted initialState: Roo
|
||||||
|
|
||||||
private fun handleUnpublishAlias(action: RoomAliasAction.UnpublishAlias) = withState { state ->
|
private fun handleUnpublishAlias(action: RoomAliasAction.UnpublishAlias) = withState { state ->
|
||||||
updateCanonicalAlias(
|
updateCanonicalAlias(
|
||||||
canonicalAlias = state.canonicalAlias,
|
// We can also unpublish the canonical alias
|
||||||
|
canonicalAlias = state.canonicalAlias.takeIf { it != action.alias },
|
||||||
alternativeAliases = state.alternativeAliases - action.alias,
|
alternativeAliases = state.alternativeAliases - action.alias,
|
||||||
closeForm = false
|
closeForm = false
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue