mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-14 19:05:27 +00:00
simplify
This commit is contained in:
+1
-1
@@ -4223,7 +4223,7 @@ sealed class ChatItemTTL: Comparable<ChatItemTTL> {
|
||||
is Seconds -> String.format(generalGetString(MR.strings.chat_item_ttl_seconds), secs)
|
||||
}
|
||||
|
||||
val doesNotExpire: Boolean get() = this is None
|
||||
val neverExpires: Boolean get() = this is None
|
||||
|
||||
companion object {
|
||||
fun fromSeconds(seconds: Long): ChatItemTTL =
|
||||
|
||||
+3
-3
@@ -1183,10 +1183,10 @@ object ChatController {
|
||||
val userId = currentUserId("getChatItemTTL")
|
||||
val r = sendCmd(rh, CC.APIGetChatItemTTL(userId))
|
||||
if (r is CR.ChatItemTTL) {
|
||||
if (r.chatItemTTL != null) {
|
||||
return ChatItemTTL.fromSeconds(r.chatItemTTL)
|
||||
return if (r.chatItemTTL != null) {
|
||||
ChatItemTTL.fromSeconds(r.chatItemTTL)
|
||||
} else {
|
||||
throw Exception("chatItemTTLResponse: invalid ttl")
|
||||
ChatItemTTL.None
|
||||
}
|
||||
}
|
||||
throw Exception("failed to get chat item TTL: ${r.responseType} ${r.details}")
|
||||
|
||||
+8
-6
@@ -1351,17 +1351,19 @@ fun setChatTTLAlert(
|
||||
previousChatTTL: ChatItemTTL?,
|
||||
progressIndicator: MutableState<Boolean>
|
||||
) {
|
||||
val disablingExpiration = selectedChatTTL.value?.doesNotExpire == true || (selectedChatTTL.value == null && chatModel.chatItemTTL.value.doesNotExpire)
|
||||
val changingExpiration = selectedChatTTL.value == null || (previousChatTTL?.doesNotExpire == false)
|
||||
val defaultTTL = chatModel.chatItemTTL.value
|
||||
val previouslyUsedTTL = previousChatTTL ?: defaultTTL
|
||||
val newTTLToUse = selectedChatTTL.value ?: defaultTTL
|
||||
|
||||
AlertManager.shared.showAlertDialog(
|
||||
title = generalGetString(
|
||||
if (disablingExpiration) {
|
||||
if (newTTLToUse.neverExpires) {
|
||||
MR.strings.disable_automatic_deletion_question
|
||||
} else if (changingExpiration) {
|
||||
} else if (!previouslyUsedTTL.neverExpires || selectedChatTTL.value == null) {
|
||||
MR.strings.change_automatic_deletion_question
|
||||
} else MR.strings.enable_automatic_deletion_question),
|
||||
text = generalGetString(if (disablingExpiration) MR.strings.disable_automatic_deletion_message else MR.strings.change_automatic_chat_deletion_message),
|
||||
confirmText = generalGetString(if (disablingExpiration) MR.strings.disable_automatic_deletion else MR.strings.delete_messages),
|
||||
text = generalGetString(if (newTTLToUse.neverExpires) MR.strings.disable_automatic_deletion_message else MR.strings.change_automatic_chat_deletion_message),
|
||||
confirmText = generalGetString(if (newTTLToUse.neverExpires) MR.strings.disable_automatic_deletion else MR.strings.delete_messages),
|
||||
onConfirm = { setChatTTL(m, rhId, chatInfo, selectedChatTTL, progressIndicator, previousChatTTL) },
|
||||
onDismiss = { selectedChatTTL.value = previousChatTTL },
|
||||
onDismissRequest = { selectedChatTTL.value = previousChatTTL },
|
||||
|
||||
Reference in New Issue
Block a user