Power level: warn when demoting yourself
This commit is contained in:
parent
a8ae4ddde8
commit
bf5ad2cf18
|
@ -102,6 +102,7 @@ class RoomMemberProfileFragment @Inject constructor(
|
||||||
is RoomMemberProfileViewEvents.StartVerification -> handleStartVerification(it)
|
is RoomMemberProfileViewEvents.StartVerification -> handleStartVerification(it)
|
||||||
is RoomMemberProfileViewEvents.ShareRoomMemberProfile -> handleShareRoomMemberProfile(it.permalink)
|
is RoomMemberProfileViewEvents.ShareRoomMemberProfile -> handleShareRoomMemberProfile(it.permalink)
|
||||||
is RoomMemberProfileViewEvents.ShowPowerLevelValidation -> handleShowPowerLevelAdminWarning(it)
|
is RoomMemberProfileViewEvents.ShowPowerLevelValidation -> handleShowPowerLevelAdminWarning(it)
|
||||||
|
is RoomMemberProfileViewEvents.ShowPowerLevelDemoteWarning -> handleShowPowerLevelDemoteWarning(it)
|
||||||
is RoomMemberProfileViewEvents.OnKickActionSuccess -> Unit
|
is RoomMemberProfileViewEvents.OnKickActionSuccess -> Unit
|
||||||
is RoomMemberProfileViewEvents.OnSetPowerLevelSuccess -> Unit
|
is RoomMemberProfileViewEvents.OnSetPowerLevelSuccess -> Unit
|
||||||
is RoomMemberProfileViewEvents.OnBanActionSuccess -> Unit
|
is RoomMemberProfileViewEvents.OnBanActionSuccess -> Unit
|
||||||
|
@ -111,6 +112,12 @@ class RoomMemberProfileFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleShowPowerLevelDemoteWarning(event: RoomMemberProfileViewEvents.ShowPowerLevelDemoteWarning) {
|
||||||
|
EditPowerLevelDialogs.showDemoteWarning(requireActivity()) {
|
||||||
|
viewModel.handle(RoomMemberProfileAction.SetPowerLevel(event.currentValue, event.newValue, false))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleShowPowerLevelAdminWarning(event: RoomMemberProfileViewEvents.ShowPowerLevelValidation) {
|
private fun handleShowPowerLevelAdminWarning(event: RoomMemberProfileViewEvents.ShowPowerLevelValidation) {
|
||||||
EditPowerLevelDialogs.showValidation(requireActivity()) {
|
EditPowerLevelDialogs.showValidation(requireActivity()) {
|
||||||
viewModel.handle(RoomMemberProfileAction.SetPowerLevel(event.currentValue, event.newValue, false))
|
viewModel.handle(RoomMemberProfileAction.SetPowerLevel(event.currentValue, event.newValue, false))
|
||||||
|
|
|
@ -31,6 +31,7 @@ sealed class RoomMemberProfileViewEvents : VectorViewEvents {
|
||||||
object OnKickActionSuccess : RoomMemberProfileViewEvents()
|
object OnKickActionSuccess : RoomMemberProfileViewEvents()
|
||||||
object OnBanActionSuccess : RoomMemberProfileViewEvents()
|
object OnBanActionSuccess : RoomMemberProfileViewEvents()
|
||||||
data class ShowPowerLevelValidation(val currentValue: Int, val newValue: Int) : RoomMemberProfileViewEvents()
|
data class ShowPowerLevelValidation(val currentValue: Int, val newValue: Int) : RoomMemberProfileViewEvents()
|
||||||
|
data class ShowPowerLevelDemoteWarning(val currentValue: Int, val newValue: Int) : RoomMemberProfileViewEvents()
|
||||||
|
|
||||||
data class StartVerification(
|
data class StartVerification(
|
||||||
val userId: String,
|
val userId: String,
|
||||||
|
|
|
@ -158,6 +158,8 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v
|
||||||
val myPowerLevel = PowerLevelsHelper(currentPowerLevelsContent).getUserPowerLevelValue(session.myUserId)
|
val myPowerLevel = PowerLevelsHelper(currentPowerLevelsContent).getUserPowerLevelValue(session.myUserId)
|
||||||
if (action.askForValidation && action.newValue >= myPowerLevel) {
|
if (action.askForValidation && action.newValue >= myPowerLevel) {
|
||||||
_viewEvents.post(RoomMemberProfileViewEvents.ShowPowerLevelValidation(action.previousValue, action.newValue))
|
_viewEvents.post(RoomMemberProfileViewEvents.ShowPowerLevelValidation(action.previousValue, action.newValue))
|
||||||
|
} else if (state.isMine) {
|
||||||
|
_viewEvents.post(RoomMemberProfileViewEvents.ShowPowerLevelDemoteWarning(action.previousValue, action.newValue))
|
||||||
} else {
|
} else {
|
||||||
currentPowerLevelsContent.users[state.userId] = action.newValue
|
currentPowerLevelsContent.users[state.userId] = action.newValue
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
|
|
|
@ -82,4 +82,15 @@ object EditPowerLevelDialogs {
|
||||||
.setNegativeButton(R.string.no, null)
|
.setNegativeButton(R.string.no, null)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showDemoteWarning(activity: Activity, onValidate: () -> Unit) {
|
||||||
|
AlertDialog.Builder(activity)
|
||||||
|
.setTitle(R.string.room_participants_power_level_demote_warning_title)
|
||||||
|
.setMessage(R.string.room_participants_power_level_demote_warning_prompt)
|
||||||
|
.setPositiveButton(R.string.room_participants_power_level_demote) { _, _ ->
|
||||||
|
onValidate()
|
||||||
|
}
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,6 +479,10 @@
|
||||||
<string name="room_participants_action_devices_list">Show Session List</string>
|
<string name="room_participants_action_devices_list">Show Session List</string>
|
||||||
<string name="room_participants_power_level_prompt">You will not be able to undo this change as you are promoting the user to have the same power level as yourself.\nAre you sure?</string>
|
<string name="room_participants_power_level_prompt">You will not be able to undo this change as you are promoting the user to have the same power level as yourself.\nAre you sure?</string>
|
||||||
|
|
||||||
|
<string name="room_participants_power_level_demote_warning_title">Demote yourself?</string>
|
||||||
|
<string name="room_participants_power_level_demote_warning_prompt">"You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the room it will be impossible to regain privileges."</string>
|
||||||
|
<string name="room_participants_power_level_demote">Demote</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="room_participants_action_ignore_title">Ignore user</string>
|
<string name="room_participants_action_ignore_title">Ignore user</string>
|
||||||
<string name="room_participants_action_ignore_prompt_msg">Ignoring this user will remove their messages from rooms you share.\n\nYou can reverse this action at any time in the general settings.</string>
|
<string name="room_participants_action_ignore_prompt_msg">Ignoring this user will remove their messages from rooms you share.\n\nYou can reverse this action at any time in the general settings.</string>
|
||||||
|
|
Loading…
Reference in New Issue