Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default permalink to access rooms by link #1072

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1040.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ajout d'un lien par défaut pour les salons sans alias accessibles par lien.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TchapRoomLinkAccessController @Inject constructor(

interface InteractionListener {
fun setLinkAccessEnabled(isEnabled: Boolean)
fun openAliasDetail(alias: String)
fun openAliasDetail(roomIdOrAlias: String)
}

var interactionListener: InteractionListener? = null
Expand Down Expand Up @@ -84,18 +84,19 @@ class TchapRoomLinkAccessController @Inject constructor(
id("LinkAccessInfo")
helperTextResId(
when {
!state.isLinkAccessEnabled -> R.string.tchap_room_settings_enable_room_access_by_link_info_off
!state.isLinkAccessEnabled -> R.string.tchap_room_settings_enable_room_access_by_link_info_off
roomType == TchapRoomType.EXTERNAL -> R.string.tchap_room_settings_enable_room_access_by_link_info_on_with_limitation
else -> R.string.tchap_room_settings_enable_room_access_by_link_info_on
else -> R.string.tchap_room_settings_enable_room_access_by_link_info_on
}
)
}

if (state.isLinkAccessEnabled && !state.canonicalAlias.isNullOrEmpty()) {
if (state.isLinkAccessEnabled) {
val roomIdOrAlias = state.canonicalAlias ?: state.roomId
profileActionItem {
id("canonicalAlias")
title(state.canonicalAlias)
listener { host.interactionListener?.openAliasDetail(state.canonicalAlias) }
title(roomIdOrAlias)
listener { host.interactionListener?.openAliasDetail(roomIdOrAlias) }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,19 @@ class TchapRoomLinkAccessFragment : VectorBaseFragment<FragmentRoomSettingGeneri

private fun handleLinkAccessAction(action: TchapRoomLinkAccessBottomSheetSharedAction) {
when (action) {
is TchapRoomLinkAccessBottomSheetSharedAction.CopyLink -> handleCopy(action.permalink)
is TchapRoomLinkAccessBottomSheetSharedAction.CopyLink -> handleCopy(action.permalink)
is TchapRoomLinkAccessBottomSheetSharedAction.ForwardLink -> handleForward(action.permalink)
is TchapRoomLinkAccessBottomSheetSharedAction.ShareLink -> handleShare(action.permalink)
is TchapRoomLinkAccessBottomSheetSharedAction.ShareLink -> handleShare(action.permalink)
}
}

override fun setLinkAccessEnabled(isEnabled: Boolean) {
viewModel.handle(TchapRoomLinkAccessAction.SetIsEnabled(isEnabled))
}

override fun openAliasDetail(alias: String) {
override fun openAliasDetail(roomIdOrAlias: String) {
TchapRoomLinkAccessBottomSheet
.newInstance(alias = alias)
.newInstance(roomIdOrAlias = roomIdOrAlias)
.show(childFragmentManager, "TCHAP_ROOM_LINK_ACCESS_ACTIONS")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import javax.inject.Inject

@Parcelize
data class RoomAliasBottomSheetArgs(
val alias: String
val roomIdOrAlias: String
) : Parcelable

/**
Expand Down Expand Up @@ -83,9 +83,9 @@ class TchapRoomLinkAccessBottomSheet :
}

companion object {
fun newInstance(alias: String): TchapRoomLinkAccessBottomSheet {
fun newInstance(roomIdOrAlias: String): TchapRoomLinkAccessBottomSheet {
return TchapRoomLinkAccessBottomSheet().apply {
setArguments(RoomAliasBottomSheetArgs(alias = alias))
setArguments(RoomAliasBottomSheetArgs(roomIdOrAlias = roomIdOrAlias))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TchapRoomLinkAccessBottomSheetController @Inject constructor() : TypedEpox
override fun buildModels(state: TchapRoomLinkAccessBottomSheetState) {
bottomSheetTitleItem {
id("alias")
title(state.alias)
title(state.roomIdOrAlias)
subTitle(state.matrixToLink)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package fr.gouv.tchap.features.roomprofile.settings.linkaccess.detail
import com.airbnb.mvrx.MavericksState

data class TchapRoomLinkAccessBottomSheetState(
val alias: String,
val roomIdOrAlias: String,
val matrixToLink: String? = null
) : MavericksState {

constructor(args: RoomAliasBottomSheetArgs) : this(alias = args.alias)
constructor(args: RoomAliasBottomSheetArgs) : this(roomIdOrAlias = args.roomIdOrAlias)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import dagger.assisted.AssistedInject
import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
import org.matrix.android.sdk.api.MatrixPatterns
import org.matrix.android.sdk.api.session.Session

class TchapRoomLinkAccessBottomSheetViewModel @AssistedInject constructor(
Expand All @@ -48,8 +49,13 @@ class TchapRoomLinkAccessBottomSheetViewModel @AssistedInject constructor(

init {
setState {
val permalink = if (MatrixPatterns.isRoomAlias(roomIdOrAlias)) {
session.permalinkService().createPermalink(roomIdOrAlias)
} else {
session.permalinkService().createRoomPermalink(roomIdOrAlias)
}
copy(
matrixToLink = session.permalinkService().createPermalink(alias)
matrixToLink = permalink
)
}
}
Expand Down
Loading