mark conversation as important

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2025-05-21 17:02:46 +02:00 committed by Marcel Hibbe
parent 62041d2581
commit 38482b8bb5
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
4 changed files with 23 additions and 29 deletions

View File

@ -1068,8 +1068,10 @@ class ConversationInfoActivity :
binding.notificationSettingsView.importantConversationSwitch.isChecked = conversation!!.hasImportant
binding.notificationSettingsView.importantConversationSwitch.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
binding.notificationSettingsView.notificationSettingsImportantConversation.setOnClickListener {
val isChecked = binding.notificationSettingsView.importantConversationSwitch.isChecked
binding.notificationSettingsView.importantConversationSwitch.isChecked = !isChecked
if (!isChecked) {
viewModel.markConversationAsImportant(
credentials,
conversationUser.baseUrl!!,
@ -1820,13 +1822,6 @@ class ConversationInfoActivity :
}
private fun setUpNotificationSettings(module: DatabaseStorageModule) {
// binding.notificationSettingsView.notificationSettingsImportantConversation.setOnClickListener {
// val isChecked = binding.notificationSettingsView.importantConversationSwitch.isChecked
// binding.notificationSettingsView.importantConversationSwitch.isChecked = !isChecked
// lifecycleScope.launch {
// module.saveBoolean("important_conversation_switch", !isChecked)
// }
// }
binding.notificationSettingsView.notificationSettingsCallNotifications.setOnClickListener {
val isChecked = binding.notificationSettingsView.callNotificationsSwitch.isChecked
binding.notificationSettingsView.callNotificationsSwitch.isChecked = !isChecked
@ -1844,9 +1839,6 @@ class ConversationInfoActivity :
}
}
// binding.notificationSettingsView.importantConversationSwitch.isChecked = module
// .getBoolean("important_conversation_switch", false)
if (conversation!!.remoteServer.isNullOrEmpty()) {
binding.notificationSettingsView.notificationSettingsCallNotifications.visibility = VISIBLE
binding.notificationSettingsView.callNotificationsSwitch.isChecked = module

View File

@ -384,7 +384,7 @@ class ConversationInfoViewModel @Inject constructor(
fun markConversationAsUnimportant(credentials: String, baseUrl: String, roomToken: String) {
viewModelScope.launch {
try {
val response = conversationsRepository.markConversationAsImportant(credentials, baseUrl, roomToken)
val response = conversationsRepository.markConversationAsUnImportant(credentials, baseUrl, roomToken)
_markConversationAsUnimportantResult.value =
MarkConversationAsUnimportantViewState.Success(response.ocs?.meta?.statusCode!!)
} catch (exception: Exception) {

View File

@ -22,6 +22,7 @@ import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.ApiUtils.getConversationApiVersion
import com.nextcloud.talk.utils.ApiUtils.getCredentials
import com.nextcloud.talk.utils.ApiUtils.getUrlForMessageExpiration
import com.nextcloud.talk.utils.ApiUtils.getUrlForRoomNotificationCalls
import com.nextcloud.talk.utils.ApiUtils.getUrlForRoomNotificationLevel
import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability
import com.nextcloud.talk.utils.SpreedFeatures
@ -64,20 +65,20 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) {
@Suppress("Detekt.TooGenericExceptionCaught")
suspend fun saveBoolean(key: String, value: Boolean) {
// if ("call_notifications_switch" == key) {
// val apiVersion = getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.API_V4))
// val url = getUrlForRoomNotificationCalls(apiVersion, conversationUser.baseUrl, conversationToken)
// val credentials = getCredentials(conversationUser.username, conversationUser.token)
// val notificationLevel = if (value) 1 else 0
// withContext(Dispatchers.IO) {
// try {
// ncApiCoroutines!!.notificationCalls(credentials!!, url, notificationLevel)
// Log.d(TAG, "Toggled notification calls")
// } catch (e: Exception) {
// Log.e(TAG, "Error when trying to toggle notification calls", e)
// }
// }
// }
if ("call_notifications_switch" == key) {
val apiVersion = getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.API_V4))
val url = getUrlForRoomNotificationCalls(apiVersion, conversationUser.baseUrl, conversationToken)
val credentials = getCredentials(conversationUser.username, conversationUser.token)
val notificationLevel = if (value) 1 else 0
withContext(Dispatchers.IO) {
try {
ncApiCoroutines!!.notificationCalls(credentials!!, url, notificationLevel)
Log.d(TAG, "Toggled notification calls")
} catch (e: Exception) {
Log.e(TAG, "Error when trying to toggle notification calls", e)
}
}
}
if ("lobby_switch" != key) {
arbitraryStorageManager!!.storeStorageSetting(
accountIdentifier,

View File

@ -46,7 +46,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/nc_important_conversation"
android:textSize="@dimen/headline_text_size" />
android:textSize="@dimen/headline_text_size"
android:clickable="false"/>
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"