mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-21 20:45:29 +03:00
check for capability before reverting status
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
7a63a645fe
commit
c4f4c857d3
2 changed files with 35 additions and 33 deletions
|
@ -283,41 +283,43 @@ class SetStatusDialogFragment :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun revertStatus() {
|
override fun revertStatus() {
|
||||||
ncApi.revertStatus(
|
if (isRestoreStatusAvailable(currentUser!!)) {
|
||||||
credentials,
|
ncApi.revertStatus(
|
||||||
ApiUtils.getUrlForRevertStatus(currentUser?.baseUrl!!, currentStatus?.messageId)
|
credentials,
|
||||||
)
|
ApiUtils.getUrlForRevertStatus(currentUser?.baseUrl!!, currentStatus?.messageId)
|
||||||
.subscribeOn(Schedulers.io())
|
)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.subscribeOn(Schedulers.io())
|
||||||
.subscribe(object : Observer<GenericOverall> {
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(object : Observer<GenericOverall> {
|
||||||
|
|
||||||
override fun onSubscribe(d: Disposable) {
|
override fun onSubscribe(d: Disposable) {
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
|
||||||
override fun onNext(genericOverall: GenericOverall) {
|
|
||||||
Log.d(TAG, "$genericOverall")
|
|
||||||
if (genericOverall.ocs?.meta?.statusCode == 200) {
|
|
||||||
Snackbar.make(
|
|
||||||
binding.root,
|
|
||||||
R.string.status_reverted,
|
|
||||||
Snackbar.LENGTH_LONG
|
|
||||||
).show()
|
|
||||||
adapter.isBackupStatusAvailable = false
|
|
||||||
predefinedStatusesList.removeAt(0)
|
|
||||||
adapter.notifyDataSetChanged()
|
|
||||||
currentStatus = backupStatus
|
|
||||||
setupCurrentStatus()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
override fun onError(e: Throwable) {
|
|
||||||
Log.e(TAG, "Error while fetching predefined statuses", e)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onComplete() {
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
}
|
override fun onNext(genericOverall: GenericOverall) {
|
||||||
})
|
Log.d(TAG, "$genericOverall")
|
||||||
|
if (genericOverall.ocs?.meta?.statusCode == 200) {
|
||||||
|
Snackbar.make(
|
||||||
|
binding.root,
|
||||||
|
R.string.status_reverted,
|
||||||
|
Snackbar.LENGTH_LONG
|
||||||
|
).show()
|
||||||
|
adapter.isBackupStatusAvailable = false
|
||||||
|
predefinedStatusesList.removeAt(0)
|
||||||
|
adapter.notifyDataSetChanged()
|
||||||
|
currentStatus = backupStatus
|
||||||
|
setupCurrentStatus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
override fun onError(e: Throwable) {
|
||||||
|
Log.e(TAG, "Error while fetching predefined statuses", e)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onComplete() {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGeneralStatusOptions() {
|
private fun setupGeneralStatusOptions() {
|
||||||
|
|
|
@ -487,7 +487,7 @@ object ApiUtils {
|
||||||
return "$baseUrl$OCS_API_VERSION/apps/user_status/api/v1/statuses/_$userId"
|
return "$baseUrl$OCS_API_VERSION/apps/user_status/api/v1/statuses/_$userId"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getUrlForRevertStatus(baseUrl: String, messageId: String?): String {
|
fun getUrlForRevertStatus(baseUrl: String, messageId: String?): String {
|
||||||
return "$baseUrl$OCS_API_VERSION/apps/user_status/api/v1/user_status/revert/$messageId"
|
return "$baseUrl$OCS_API_VERSION/apps/user_status/api/v1/user_status/revert/$messageId"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue