mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-28 21:18:18 +00:00
core, ui: allow to choose disappearing messages ttl in user profile (#6097)
This commit is contained in:
+3
@@ -4925,6 +4925,9 @@ data class TimedMessagesPreference(
|
||||
companion object {
|
||||
val ttlValues: List<Int?>
|
||||
get() = listOf(600, 3600, 86400, 7 * 86400, 30 * 86400, 3 * 30 * 86400, null)
|
||||
|
||||
val profileLevelTTLValues: List<Int?>
|
||||
get() = listOf(7 * 86400, 30 * 86400, 3 * 30 * 86400, null)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+34
-4
@@ -69,9 +69,18 @@ private fun PreferencesLayout(
|
||||
ColumnWithScrollBar {
|
||||
AppBarTitle(stringResource(MR.strings.your_preferences))
|
||||
val timedMessages = remember(preferences) { mutableStateOf(preferences.timedMessages.allow) }
|
||||
TimedMessagesFeatureSection(timedMessages) {
|
||||
applyPrefs(preferences.copy(timedMessages = TimedMessagesPreference(allow = if (it) FeatureAllowed.YES else FeatureAllowed.NO)))
|
||||
val onTTLUpdated = { ttl: Int? ->
|
||||
applyPrefs(preferences.copy(timedMessages = preferences.timedMessages.copy(ttl = ttl)))
|
||||
}
|
||||
TimedMessagesFeatureSection(
|
||||
preferences,
|
||||
timedMessages,
|
||||
onSelected = {
|
||||
applyPrefs(preferences.copy(timedMessages = TimedMessagesPreference(allow = if (it) FeatureAllowed.YES else FeatureAllowed.NO)))
|
||||
},
|
||||
onTTLUpdated = onTTLUpdated
|
||||
)
|
||||
|
||||
SectionDividerSpaced(true, maxBottomPadding = false)
|
||||
val allowFullDeletion = remember(preferences) { mutableStateOf(preferences.fullDelete.allow) }
|
||||
FeatureSection(ChatFeature.FullDelete, allowFullDeletion) {
|
||||
@@ -117,7 +126,13 @@ private fun FeatureSection(feature: ChatFeature, allowFeature: State<FeatureAllo
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TimedMessagesFeatureSection(allowFeature: State<FeatureAllowed>, onSelected: (Boolean) -> Unit) {
|
||||
private fun TimedMessagesFeatureSection(
|
||||
preferences: FullChatPreferences,
|
||||
allowFeature: State<FeatureAllowed>,
|
||||
onSelected: (Boolean) -> Unit,
|
||||
onTTLUpdated: (Int?) -> Unit
|
||||
) {
|
||||
val ttl = rememberSaveable(preferences) { mutableStateOf(preferences.timedMessages.ttl) }
|
||||
SectionView {
|
||||
PreferenceToggleWithIcon(
|
||||
ChatFeature.TimedMessages.text,
|
||||
@@ -127,8 +142,23 @@ private fun TimedMessagesFeatureSection(allowFeature: State<FeatureAllowed>, onS
|
||||
extraPadding = false,
|
||||
onChange = onSelected
|
||||
)
|
||||
if (allowFeature.value == FeatureAllowed.ALWAYS || allowFeature.value == FeatureAllowed.YES) {
|
||||
ExposedDropDownSettingRow(
|
||||
generalGetString(MR.strings.delete_after),
|
||||
TimedMessagesPreference.profileLevelTTLValues.map { v -> v to timeText(v) },
|
||||
ttl,
|
||||
icon = null,
|
||||
onSelected = onTTLUpdated
|
||||
)
|
||||
}
|
||||
}
|
||||
SectionTextFooter(ChatFeature.TimedMessages.allowDescription(allowFeature.value))
|
||||
SectionTextFooter(
|
||||
if ((allowFeature.value == FeatureAllowed.ALWAYS || allowFeature.value == FeatureAllowed.YES) && ttl.value != null) {
|
||||
ChatFeature.TimedMessages.allowDescription(allowFeature.value) + "\n" + generalGetString(MR.strings.time_to_disappear_is_set_only_for_new_contacts)
|
||||
} else {
|
||||
ChatFeature.TimedMessages.allowDescription(allowFeature.value)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -2138,6 +2138,7 @@
|
||||
<string name="accept_feature_set_1_day">Set 1 day</string>
|
||||
<string name="allow_your_contacts_to_send_disappearing_messages">Allow your contacts to send disappearing messages.</string>
|
||||
<string name="allow_disappearing_messages_only_if">Allow disappearing messages only if your contact allows them.</string>
|
||||
<string name="time_to_disappear_is_set_only_for_new_contacts">Time to disappear is set only for new contacts.</string>
|
||||
<string name="prohibit_sending_disappearing_messages">Prohibit sending disappearing messages.</string>
|
||||
<string name="allow_your_contacts_irreversibly_delete">Allow your contacts to irreversibly delete sent messages. (24 hours)</string>
|
||||
<string name="allow_irreversible_message_deletion_only_if">Allow irreversible message deletion only if your contact allows it to you. (24 hours)</string>
|
||||
|
||||
Reference in New Issue
Block a user