mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
core, mobile: logic for enabling disappearing messages (#1588)
* core: logic for enabled for disappearing messages * refactor * update feature enabled in UI
This commit is contained in:
committed by
GitHub
parent
6b8705e9f4
commit
8786e2147a
@@ -2101,10 +2101,10 @@ data class FeatureEnabled(
|
||||
get() = if (forUser) SimplexGreen else if (forContact) WarningYellow else HighOrLowlight
|
||||
|
||||
companion object {
|
||||
fun enabled(user: ChatPreference, contact: ChatPreference): FeatureEnabled =
|
||||
fun enabled(asymmetric: Boolean, user: ChatPreference, contact: ChatPreference): FeatureEnabled =
|
||||
when {
|
||||
user.allow == FeatureAllowed.ALWAYS && contact.allow == FeatureAllowed.NO -> FeatureEnabled(forUser = false, forContact = true)
|
||||
user.allow == FeatureAllowed.NO && contact.allow == FeatureAllowed.ALWAYS -> FeatureEnabled(forUser = true, forContact = false)
|
||||
user.allow == FeatureAllowed.ALWAYS && contact.allow == FeatureAllowed.NO -> FeatureEnabled(forUser = false, forContact = asymmetric)
|
||||
user.allow == FeatureAllowed.NO && contact.allow == FeatureAllowed.ALWAYS -> FeatureEnabled(forUser = asymmetric, forContact = false)
|
||||
contact.allow == FeatureAllowed.NO -> FeatureEnabled(forUser = false, forContact = false)
|
||||
user.allow == FeatureAllowed.NO -> FeatureEnabled(forUser = false, forContact = false)
|
||||
else -> FeatureEnabled(forUser = true, forContact = true)
|
||||
@@ -2138,6 +2138,11 @@ enum class ChatFeature: Feature {
|
||||
@SerialName("fullDelete") FullDelete,
|
||||
@SerialName("voice") Voice;
|
||||
|
||||
val asymmetric: Boolean get() = when (this) {
|
||||
TimedMessages -> false
|
||||
else -> true
|
||||
}
|
||||
|
||||
override val text: String
|
||||
get() = when(this) {
|
||||
TimedMessages -> generalGetString(R.string.timed_messages)
|
||||
|
||||
@@ -112,6 +112,7 @@ private fun FeatureSection(
|
||||
onSelected: (ContactFeatureAllowed) -> Unit
|
||||
) {
|
||||
val enabled = FeatureEnabled.enabled(
|
||||
feature.asymmetric,
|
||||
user = ChatPreference(allow = allowFeature.value.allowed),
|
||||
contact = pref.contactPreference
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user