mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
More fixes
This commit is contained in:
parent
2d4cbde72c
commit
a570528f6c
@ -51,7 +51,7 @@ class RoomAliasController @Inject constructor(
|
||||
fun toggleLocalAliasForm()
|
||||
fun setNewLocalAliasLocalPart(value: String)
|
||||
fun addLocalAlias()
|
||||
fun openAliasDetail(alias: String, isPublished: Boolean)
|
||||
fun openAliasDetail(alias: String)
|
||||
}
|
||||
|
||||
var callback: Callback? = null
|
||||
@ -86,7 +86,7 @@ class RoomAliasController @Inject constructor(
|
||||
id("canonical")
|
||||
title(data.canonicalAlias)
|
||||
subtitle(stringProvider.getString(R.string.room_alias_published_alias_main))
|
||||
listener { callback?.openAliasDetail(canonicalAlias, true) }
|
||||
listener { callback?.openAliasDetail(canonicalAlias) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ class RoomAliasController @Inject constructor(
|
||||
profileActionItem {
|
||||
id("alt_$idx")
|
||||
title(altAlias)
|
||||
listener { callback?.openAliasDetail(altAlias, true) }
|
||||
listener { callback?.openAliasDetail(altAlias) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,7 +169,7 @@ class RoomAliasController @Inject constructor(
|
||||
profileActionItem {
|
||||
id("loc_$idx")
|
||||
title(localAlias)
|
||||
listener { callback?.openAliasDetail(localAlias, false) }
|
||||
listener { callback?.openAliasDetail(localAlias) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,12 +162,13 @@ class RoomAliasFragment @Inject constructor(
|
||||
viewModel.handle(RoomAliasAction.AddLocalAlias)
|
||||
}
|
||||
|
||||
override fun openAliasDetail(alias: String, isPublished: Boolean) = withState(viewModel) { state ->
|
||||
override fun openAliasDetail(alias: String) = withState(viewModel) { state ->
|
||||
RoomAliasBottomSheet
|
||||
.newInstance(
|
||||
alias = alias,
|
||||
isPublished = isPublished,
|
||||
isPublished = alias in state.allPublishedAliases,
|
||||
isMainAlias = alias == state.canonicalAlias,
|
||||
isLocal = alias in state.localAliases().orEmpty(),
|
||||
canEditCanonicalAlias = state.actionPermissions.canChangeCanonicalAlias
|
||||
)
|
||||
.show(childFragmentManager, "ROOM_ALIAS_ACTIONS")
|
||||
|
@ -236,7 +236,7 @@ class RoomAliasViewModel @AssistedInject constructor(@Assisted initialState: Roo
|
||||
updateCanonicalAlias(
|
||||
canonicalAlias = action.canonicalAlias,
|
||||
// Ensure the previous canonical alias is moved to the alt aliases
|
||||
alternativeAliases = (state.alternativeAliases + listOfNotNull(state.canonicalAlias)).distinct(),
|
||||
alternativeAliases = state.allPublishedAliases,
|
||||
closeForm = false
|
||||
)
|
||||
}
|
||||
|
@ -37,6 +37,9 @@ data class RoomAliasViewState(
|
||||
|
||||
constructor(args: RoomProfileArgs) : this(roomId = args.roomId)
|
||||
|
||||
val allPublishedAliases: List<String>
|
||||
get() = (alternativeAliases + listOfNotNull(canonicalAlias)).distinct()
|
||||
|
||||
data class ActionPermissions(
|
||||
val canChangeCanonicalAlias: Boolean = false
|
||||
)
|
||||
|
@ -36,6 +36,7 @@ data class RoomAliasBottomSheetArgs(
|
||||
val alias: String,
|
||||
val isPublished: Boolean,
|
||||
val isMainAlias: Boolean,
|
||||
val isLocal: Boolean,
|
||||
val canEditCanonicalAlias: Boolean
|
||||
) : Parcelable
|
||||
|
||||
@ -90,12 +91,14 @@ class RoomAliasBottomSheet : VectorBaseBottomSheetDialogFragment(), RoomAliasBot
|
||||
fun newInstance(alias: String,
|
||||
isPublished: Boolean,
|
||||
isMainAlias: Boolean,
|
||||
isLocal: Boolean,
|
||||
canEditCanonicalAlias: Boolean): RoomAliasBottomSheet {
|
||||
return RoomAliasBottomSheet().apply {
|
||||
setArguments(RoomAliasBottomSheetArgs(
|
||||
alias = alias,
|
||||
isPublished = isPublished,
|
||||
isMainAlias = isMainAlias,
|
||||
isLocal = isLocal,
|
||||
canEditCanonicalAlias = canEditCanonicalAlias
|
||||
))
|
||||
}
|
||||
|
@ -59,9 +59,11 @@ class RoomAliasBottomSheetController @Inject constructor() : TypedEpoxyControlle
|
||||
}
|
||||
RoomAliasBottomSheetSharedAction.UnPublishAlias(state.alias).toBottomSheetItem(++idx)
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
if (state.isLocal) {
|
||||
// Local address
|
||||
if (state.canEditCanonicalAlias) {
|
||||
if (state.canEditCanonicalAlias && state.isPublished.not()) {
|
||||
// Publish
|
||||
RoomAliasBottomSheetSharedAction.PublishAlias(state.alias).toBottomSheetItem(++idx)
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ data class RoomAliasBottomSheetState(
|
||||
val matrixToLink: String? = null,
|
||||
val isPublished: Boolean,
|
||||
val isMainAlias: Boolean,
|
||||
val isLocal: Boolean,
|
||||
val canEditCanonicalAlias: Boolean
|
||||
) : MvRxState {
|
||||
|
||||
@ -30,6 +31,7 @@ data class RoomAliasBottomSheetState(
|
||||
alias = args.alias,
|
||||
isPublished = args.isPublished,
|
||||
isMainAlias = args.isMainAlias,
|
||||
isLocal = args.isLocal,
|
||||
canEditCanonicalAlias = args.canEditCanonicalAlias
|
||||
)
|
||||
}
|
||||
|
@ -1034,7 +1034,7 @@
|
||||
<string name="room_alias_published_alias_main">This is the main address</string>
|
||||
<string name="room_alias_main_address_hint">Main address</string>
|
||||
<string name="room_alias_published_other">Other published addresses:</string>
|
||||
<string name="room_alias_published_alias_add_manually">Published a new address manually</string>
|
||||
<string name="room_alias_published_alias_add_manually">Publish a new address manually</string>
|
||||
<string name="room_alias_published_alias_add_manually_submit">Publish</string>
|
||||
<string name="room_alias_unpublish_confirmation">Unpublish the address \"%1$s\"?</string>
|
||||
<string name="room_alias_delete_confirmation">Delete the address \"%1$s\"?</string>
|
||||
|
Loading…
Reference in New Issue
Block a user