refactor code

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-11-12 16:53:29 +01:00 committed by Marcel Hibbe
parent 99d73e15e0
commit 9f3bbf6ebf
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
2 changed files with 17 additions and 12 deletions

View file

@ -121,14 +121,14 @@ interface NcApiCoroutines {
@POST
suspend fun setReadStatusPrivacy(
@Header("Authorization") authorization: String?,
@Header("Authorization") authorization: String,
@Url url: String,
@Body body: RequestBody
): GenericOverall
@POST
suspend fun setTypingStatusPrivacy(
@Header("Authorization") authorization: String?,
@Header("Authorization") authorization: String,
@Url url: String,
@Body body: RequestBody
): GenericOverall

View file

@ -1285,11 +1285,13 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
val booleanValue = if (newBoolean) "0" else "1"
val json = "{\"key\": \"read_status_privacy\", \"value\" : $booleanValue}"
try {
credentials?.let { credentials ->
ncApiCoroutines.setReadStatusPrivacy(
ApiUtils.getCredentials(currentUser!!.username, currentUser!!.token),
credentials,
ApiUtils.getUrlForUserSettings(currentUser!!.baseUrl!!),
json.toRequestBody("application/json".toMediaTypeOrNull())
)
}
Log.i(TAG, "reading status set")
} catch (e: Exception) {
appPreferences.setReadPrivacy(!newBoolean)
@ -1310,11 +1312,14 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu
val json = "{\"key\": \"typing_privacy\", \"value\" : $booleanValue}"
try {
credentials?.let { credentials ->
ncApiCoroutines.setTypingStatusPrivacy(
ApiUtils.getCredentials(currentUser!!.username, currentUser!!.token),
credentials,
ApiUtils.getUrlForUserSettings(currentUser!!.baseUrl!!),
json.toRequestBody("application/json".toMediaTypeOrNull())
)
}
loadCapabilitiesAndUpdateSettings()
Log.i(TAG, "typing status set")
} catch (e: Exception) {