mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 14:24:05 +01:00
Deduplicate the subscriber to make the method shorter
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
eba6fe0829
commit
9596e298f2
@ -696,7 +696,24 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleModeratorStatus(apiVersion: Int, participant: Participant) {
|
private fun toggleModeratorStatus(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 (apiVersion >= ApiUtils.APIv4) {
|
if (apiVersion >= ApiUtils.APIv4) {
|
||||||
if (participant.type == Participant.ParticipantType.MODERATOR) {
|
if (participant.type == Participant.ParticipantType.MODERATOR) {
|
||||||
ncApi.demoteAttendeeFromModerator(
|
ncApi.demoteAttendeeFromModerator(
|
||||||
@ -710,22 +727,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
)
|
)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(object : Observer<GenericOverall> {
|
.subscribe(subscriber)
|
||||||
override fun onSubscribe(d: Disposable) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNext(genericOverall: GenericOverall) {
|
|
||||||
getListOfParticipants()
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("LongLogTag")
|
|
||||||
override fun onError(e: Throwable) {
|
|
||||||
Log.e(TAG, "Error demoting an attendee from moderators", e)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onComplete() {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else if (participant.type == Participant.ParticipantType.USER) {
|
} else if (participant.type == Participant.ParticipantType.USER) {
|
||||||
ncApi.promoteAttendeeToModerator(
|
ncApi.promoteAttendeeToModerator(
|
||||||
credentials,
|
credentials,
|
||||||
@ -738,22 +740,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
)
|
)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(object : Observer<GenericOverall> {
|
.subscribe(subscriber)
|
||||||
override fun onSubscribe(d: Disposable) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNext(genericOverall: GenericOverall) {
|
|
||||||
getListOfParticipants()
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("LongLogTag")
|
|
||||||
override fun onError(e: Throwable) {
|
|
||||||
Log.e(TAG, "Error promoting an attendee to moderators", e)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onComplete() {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (participant.type == Participant.ParticipantType.MODERATOR) {
|
if (participant.type == Participant.ParticipantType.MODERATOR) {
|
||||||
@ -768,22 +755,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
)
|
)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(object : Observer<GenericOverall> {
|
.subscribe(subscriber)
|
||||||
override fun onSubscribe(d: Disposable) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNext(genericOverall: GenericOverall) {
|
|
||||||
getListOfParticipants()
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("LongLogTag")
|
|
||||||
override fun onError(e: Throwable) {
|
|
||||||
Log.e(TAG, "Error demoting a user from moderators", e)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onComplete() {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else if (participant.type == Participant.ParticipantType.USER) {
|
} else if (participant.type == Participant.ParticipantType.USER) {
|
||||||
ncApi.promoteUserToModerator(
|
ncApi.promoteUserToModerator(
|
||||||
credentials,
|
credentials,
|
||||||
@ -796,22 +768,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
)
|
)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(object : Observer<GenericOverall> {
|
.subscribe(subscriber)
|
||||||
override fun onSubscribe(d: Disposable) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNext(genericOverall: GenericOverall) {
|
|
||||||
getListOfParticipants()
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("LongLogTag")
|
|
||||||
override fun onError(e: Throwable) {
|
|
||||||
Log.e(TAG, "Error promoting a user to moderators", e)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onComplete() {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user