From 30687f5fa6bc64e855c0a5c505682f7735d57dc7 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Tue, 20 Jun 2023 10:13:16 +0400 Subject: [PATCH] ios, android: allow to set custom ttl per message if conversation timer is not set (#2598) --- .../java/chat/simplex/app/views/chat/ComposeView.kt | 4 +--- .../simplex/app/views/chat/group/GroupPreferences.kt | 12 ++++++------ .../Views/Chat/ComposeMessage/ComposeView.swift | 4 +--- .../Views/Chat/Group/GroupPreferencesView.swift | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ComposeView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ComposeView.kt index d00548f755..32f68a8b91 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ComposeView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ComposeView.kt @@ -790,9 +790,7 @@ fun ComposeView( } } - // TODO in 5.2 - allow if ttl is not configured - // val timedMessageAllowed = remember(chat.chatInfo) { chat.chatInfo.featureEnabled(ChatFeature.TimedMessages) } - val timedMessageAllowed = remember(chat.chatInfo) { chat.chatInfo.featureEnabled(ChatFeature.TimedMessages) && chat.chatInfo.timedMessagesTTL != null } + val timedMessageAllowed = remember(chat.chatInfo) { chat.chatInfo.featureEnabled(ChatFeature.TimedMessages) } SendMsgView( composeState, showVoiceRecordIcon = true, diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupPreferences.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupPreferences.kt index baf62fd56f..e23f0dd264 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupPreferences.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupPreferences.kt @@ -30,9 +30,9 @@ fun GroupPreferencesView(m: ChatModel, chatId: String, close: () -> Unit,) { fun savePrefs(afterSave: () -> Unit = {}) { withApi { val gp = gInfo.groupProfile.copy(groupPreferences = preferences.toGroupPreferences()) - val gInfo = m.controller.apiUpdateGroup(gInfo.groupId, gp) - if (gInfo != null) { - m.updateGroup(gInfo) + val g = m.controller.apiUpdateGroup(gInfo.groupId, gp) + if (g != null) { + m.updateGroup(g) currentPreferences = preferences } afterSave() @@ -74,11 +74,11 @@ private fun GroupPreferencesLayout( AppBarTitle(stringResource(R.string.group_preferences)) val timedMessages = remember(preferences) { mutableStateOf(preferences.timedMessages.enable) } val onTTLUpdated = { ttl: Int? -> - applyPrefs(preferences.copy(timedMessages = preferences.timedMessages.copy(ttl = ttl ?: 86400))) + applyPrefs(preferences.copy(timedMessages = preferences.timedMessages.copy(ttl = ttl))) } FeatureSection(GroupFeature.TimedMessages, timedMessages, groupInfo, preferences, onTTLUpdated) { enable -> if (enable == GroupFeatureEnabled.ON) { - applyPrefs(preferences.copy(timedMessages = TimedMessagesGroupPreference(enable = enable, ttl = preferences.timedMessages.ttl ?: 86400))) + applyPrefs(preferences.copy(timedMessages = TimedMessagesGroupPreference(enable = enable, ttl = preferences.timedMessages.ttl ?: 86400))) } else { applyPrefs(preferences.copy(timedMessages = TimedMessagesGroupPreference(enable = enable, ttl = currentPreferences.timedMessages.ttl))) } @@ -144,7 +144,7 @@ private fun FeatureSection( selection = ttl, propagateExternalSelectionUpdate = true, // for Reset label = generalGetString(R.string.delete_after), - dropdownValues = TimedMessagesPreference.ttlValues.filterNotNull(), // TODO in 5.2 - allow "off" + dropdownValues = TimedMessagesPreference.ttlValues, customPickerTitle = generalGetString(R.string.delete_after), customPickerConfirmButtonText = generalGetString(R.string.custom_time_picker_select), onSelected = onTTLUpdated diff --git a/apps/ios/Shared/Views/Chat/ComposeMessage/ComposeView.swift b/apps/ios/Shared/Views/Chat/ComposeMessage/ComposeView.swift index a261471a51..a70f79ecb8 100644 --- a/apps/ios/Shared/Views/Chat/ComposeMessage/ComposeView.swift +++ b/apps/ios/Shared/Views/Chat/ComposeMessage/ComposeView.swift @@ -296,9 +296,7 @@ struct ComposeView: View { }, finishVoiceMessageRecording: finishVoiceMessageRecording, allowVoiceMessagesToContact: allowVoiceMessagesToContact, - // TODO in 5.2 - allow if ttl is not configured - // timedMessageAllowed: chat.chatInfo.featureEnabled(.timedMessages), - timedMessageAllowed: chat.chatInfo.featureEnabled(.timedMessages) && chat.chatInfo.timedMessagesTTL != nil, + timedMessageAllowed: chat.chatInfo.featureEnabled(.timedMessages), onMediaAdded: { media in if !media.isEmpty { chosenMedia = media }}, keyboardVisible: $keyboardVisible ) diff --git a/apps/ios/Shared/Views/Chat/Group/GroupPreferencesView.swift b/apps/ios/Shared/Views/Chat/Group/GroupPreferencesView.swift index c3db8cba15..c013c29f1b 100644 --- a/apps/ios/Shared/Views/Chat/Group/GroupPreferencesView.swift +++ b/apps/ios/Shared/Views/Chat/Group/GroupPreferencesView.swift @@ -79,7 +79,7 @@ struct GroupPreferencesView: View { DropdownCustomTimePicker( selection: $preferences.timedMessages.ttl, label: "Delete after", - dropdownValues: TimedMessagesPreference.ttlValues.filter { $0 != nil }, // TODO in 5.2 - allow "off" + dropdownValues: TimedMessagesPreference.ttlValues, customPickerConfirmButtonText: "Select", customPickerDescription: "Delete after" )