mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 04:29:45 +01:00
Split the method to be short *roll eyes*
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
9596e298f2
commit
d29905d0fa
@ -714,8 +714,8 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apiVersion >= ApiUtils.APIv4) {
|
if (participant.type == Participant.ParticipantType.MODERATOR ||
|
||||||
if (participant.type == Participant.ParticipantType.MODERATOR) {
|
participant.type == Participant.ParticipantType.GUEST_MODERATOR) {
|
||||||
ncApi.demoteAttendeeFromModerator(
|
ncApi.demoteAttendeeFromModerator(
|
||||||
credentials,
|
credentials,
|
||||||
ApiUtils.getUrlForRoomModerators(
|
ApiUtils.getUrlForRoomModerators(
|
||||||
@ -728,7 +728,8 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(subscriber)
|
.subscribe(subscriber)
|
||||||
} else if (participant.type == Participant.ParticipantType.USER) {
|
} else if (participant.type == Participant.ParticipantType.USER ||
|
||||||
|
participant.type == Participant.ParticipantType.GUEST) {
|
||||||
ncApi.promoteAttendeeToModerator(
|
ncApi.promoteAttendeeToModerator(
|
||||||
credentials,
|
credentials,
|
||||||
ApiUtils.getUrlForRoomModerators(
|
ApiUtils.getUrlForRoomModerators(
|
||||||
@ -742,7 +743,26 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(subscriber)
|
.subscribe(subscriber)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
private fun toggleModeratorStatusLegacy(apiVersion: Int, participant: Participant) {
|
||||||
|
val subscriber = object : Observer<GenericOverall> {
|
||||||
|
override fun onSubscribe(d: Disposable) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNext(genericOverall: GenericOverall) {
|
||||||
|
getListOfParticipants()
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("LongLogTag")
|
||||||
|
override fun onError(e: Throwable) {
|
||||||
|
Log.e(TAG, "Error toggling moderator status", e)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onComplete() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (participant.type == Participant.ParticipantType.MODERATOR) {
|
if (participant.type == Participant.ParticipantType.MODERATOR) {
|
||||||
ncApi.demoteModeratorToUser(
|
ncApi.demoteModeratorToUser(
|
||||||
credentials,
|
credentials,
|
||||||
@ -771,7 +791,6 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
.subscribe(subscriber)
|
.subscribe(subscriber)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun removeAttendeeFromConversation(apiVersion: Int, participant: Participant) {
|
fun removeAttendeeFromConversation(apiVersion: Int, participant: Participant) {
|
||||||
if (apiVersion >= ApiUtils.APIv4) {
|
if (apiVersion >= ApiUtils.APIv4) {
|
||||||
@ -971,7 +990,11 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
// Pin, nothing to do
|
// Pin, nothing to do
|
||||||
} else if (actionToTrigger == 1) {
|
} else if (actionToTrigger == 1) {
|
||||||
// Promote/demote
|
// Promote/demote
|
||||||
|
if (apiVersion >= ApiUtils.APIv4) {
|
||||||
toggleModeratorStatus(apiVersion, participant)
|
toggleModeratorStatus(apiVersion, participant)
|
||||||
|
} else {
|
||||||
|
toggleModeratorStatusLegacy(apiVersion, participant)
|
||||||
|
}
|
||||||
} else if (actionToTrigger == 2) {
|
} else if (actionToTrigger == 2) {
|
||||||
// Remove from conversation
|
// Remove from conversation
|
||||||
removeAttendeeFromConversation(apiVersion, participant)
|
removeAttendeeFromConversation(apiVersion, participant)
|
||||||
|
Loading…
Reference in New Issue
Block a user