core: change default for Disappearing Messages to "allow", mobile: support disabling without prohibiting (#2192)
* core: change default for Disappearing Messages to "allow", mobile: support disabling without prohibiting * fix tests * disable tests back in CI * fixed tests 2 * remove enable Co-authored-by: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> --------- Co-authored-by: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
9edbe2e589
commit
5f41cf3c52
@@ -2460,7 +2460,7 @@ data class TimedMessagesPreference(
|
||||
): ChatPreference {
|
||||
companion object {
|
||||
val ttlValues: List<Int?>
|
||||
get() = listOf(30, 300, 3600, 8 * 3600, 86400, 7 * 86400, 30 * 86400)
|
||||
get() = listOf(30, 300, 3600, 8 * 3600, 86400, 7 * 86400, 30 * 86400, null)
|
||||
|
||||
fun ttlText(ttl: Int?): String {
|
||||
ttl ?: return generalGetString(R.string.feature_off)
|
||||
@@ -2593,12 +2593,6 @@ sealed class ContactUserPref {
|
||||
@Serializable @SerialName("user") data class User(val preference: SimpleChatPreference): ContactUserPref() {
|
||||
override val pref get() = preference
|
||||
}
|
||||
|
||||
val contactOverride: SimpleChatPreference?
|
||||
get() = when(this) {
|
||||
is Contact -> pref
|
||||
is User -> null
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@@ -2613,12 +2607,6 @@ sealed class ContactUserPrefTimed {
|
||||
@Serializable @SerialName("user") data class User(val preference: TimedMessagesPreference): ContactUserPrefTimed() {
|
||||
override val pref get() = preference
|
||||
}
|
||||
|
||||
val contactOverride: TimedMessagesPreference?
|
||||
get() = when(this) {
|
||||
is Contact -> pref
|
||||
is User -> null
|
||||
}
|
||||
}
|
||||
|
||||
interface Feature {
|
||||
@@ -2831,7 +2819,7 @@ data class ContactFeaturesAllowed(
|
||||
|
||||
fun contactUserPrefsToFeaturesAllowed(contactUserPreferences: ContactUserPreferences): ContactFeaturesAllowed {
|
||||
val pref = contactUserPreferences.timedMessages.userPreference
|
||||
val allow = pref.contactOverride?.allow
|
||||
val allow = pref.pref.allow
|
||||
return ContactFeaturesAllowed(
|
||||
timedMessagesAllowed = allow == FeatureAllowed.YES || allow == FeatureAllowed.ALWAYS,
|
||||
timedMessagesTTL = pref.pref.ttl,
|
||||
|
||||
@@ -88,7 +88,7 @@ private fun ContactPreferencesLayout(
|
||||
AppBarTitle(stringResource(R.string.contact_preferences))
|
||||
val timedMessages: MutableState<Boolean> = remember(featuresAllowed) { mutableStateOf(featuresAllowed.timedMessagesAllowed) }
|
||||
val onTTLUpdated = { ttl: Int? ->
|
||||
applyPrefs(featuresAllowed.copy(timedMessagesTTL = ttl ?: 86400))
|
||||
applyPrefs(featuresAllowed.copy(timedMessagesTTL = ttl))
|
||||
}
|
||||
TimedMessagesFeatureSection(featuresAllowed, contact.mergedPreferences.timedMessages, timedMessages, onTTLUpdated) { allowed, ttl ->
|
||||
applyPrefs(featuresAllowed.copy(timedMessagesAllowed = allowed, timedMessagesTTL = ttl ?: currentFeaturesAllowed.timedMessagesTTL))
|
||||
|
||||
@@ -71,7 +71,7 @@ struct ChatListView: View {
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button {
|
||||
if chatModel.users.filter { u in u.user.activeUser || !u.user.hidden }.count > 1 {
|
||||
if chatModel.users.filter({ u in u.user.activeUser || !u.user.hidden }).count > 1 {
|
||||
withAnimation {
|
||||
userPickerVisible.toggle()
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ public struct TimedMessagesPreference: Preference {
|
||||
}
|
||||
|
||||
public static var ttlValues: [Int?] {
|
||||
[30, 300, 3600, 8 * 3600, 86400, 7 * 86400, 30 * 86400]
|
||||
[30, 300, 3600, 8 * 3600, 86400, 7 * 86400, 30 * 86400, nil]
|
||||
}
|
||||
|
||||
public static func ttlText(_ ttl: Int?) -> String {
|
||||
@@ -391,13 +391,6 @@ public enum ContactUserPref<P: Preference>: Decodable {
|
||||
case let .user(preference): return preference
|
||||
}
|
||||
}
|
||||
|
||||
var contactOverride: P? {
|
||||
switch self {
|
||||
case let .contact(preference): return preference
|
||||
case .user: return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public protocol Feature {
|
||||
@@ -671,7 +664,7 @@ public struct ContactFeaturesAllowed: Equatable {
|
||||
|
||||
public func contactUserPrefsToFeaturesAllowed(_ contactUserPreferences: ContactUserPreferences) -> ContactFeaturesAllowed {
|
||||
let pref = contactUserPreferences.timedMessages.userPreference
|
||||
let allow = pref.contactOverride?.allow
|
||||
let allow = pref.preference.allow
|
||||
return ContactFeaturesAllowed(
|
||||
timedMessagesAllowed: allow == .yes || allow == .always,
|
||||
timedMessagesTTL: pref.preference.ttl,
|
||||
@@ -2129,7 +2122,7 @@ public enum CIContent: Decodable, ItemContent {
|
||||
case let .sndCall(status, duration): return status.text(duration)
|
||||
case let .rcvCall(status, duration): return status.text(duration)
|
||||
case let .rcvIntegrityError(msgError): return msgError.text
|
||||
case let .rcvDecryptionError(msgDecryptError, msgCount): return msgDecryptError.text
|
||||
case let .rcvDecryptionError(msgDecryptError, _): return msgDecryptError.text
|
||||
case let .rcvGroupInvitation(groupInvitation, _): return groupInvitation.text
|
||||
case let .sndGroupInvitation(groupInvitation, _): return groupInvitation.text
|
||||
case let .rcvGroupEvent(rcvGroupEvent): return rcvGroupEvent.text
|
||||
|
||||
Reference in New Issue
Block a user