From cf158ed12992b4000bd19b9c2c06d8700eb15651 Mon Sep 17 00:00:00 2001 From: Diogo Date: Wed, 22 Jan 2025 13:03:18 +0000 Subject: [PATCH] only disable ttl --- .../simplex/common/views/chat/ChatInfoView.kt | 28 ++++-------- .../views/chat/group/GroupChatInfoView.kt | 44 +++++++++++-------- .../common/views/chat/group/GroupLinkView.kt | 4 +- 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatInfoView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatInfoView.kt index 7449167874..166d1bd678 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatInfoView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatInfoView.kt @@ -42,6 +42,7 @@ import chat.simplex.common.ui.theme.* import chat.simplex.common.views.helpers.* import chat.simplex.common.views.usersettings.* import chat.simplex.common.platform.* +import chat.simplex.common.views.chat.group.ChatTTLSection import chat.simplex.common.views.chat.group.ProgressIndicator import chat.simplex.common.views.chatlist.updateChatSettings import chat.simplex.common.views.database.* @@ -78,7 +79,7 @@ fun ChatInfoView( val chatRh = chat.remoteHostId val sendReceipts = remember(contact.id) { mutableStateOf(SendReceipts.fromBool(contact.chatSettings.sendRcpts, currentUser.sendRcptsContacts)) } val chatItemTTL = remember(contact.id) { mutableStateOf(if (contact.chatItemTTL != null) ChatItemTTL.fromSeconds(contact.chatItemTTL) else null) } - val progressIndicator = rememberSaveable(contact.id) { mutableStateOf(false) } + val deletingItems = rememberSaveable(contact.id) { mutableStateOf(false) } ChatInfoLayout( chat, @@ -98,7 +99,7 @@ fun ChatInfoView( val previousChatTTL = chatItemTTL.value chatItemTTL.value = it - setChatTTLAlert(chat.remoteHostId, chat.chatInfo, chatItemTTL, previousChatTTL, progressIndicator) + setChatTTLAlert(chat.remoteHostId, chat.chatInfo, chatItemTTL, previousChatTTL, deletingItems) }, connStats = connStats, contactNetworkStatus.value, @@ -190,12 +191,8 @@ fun ChatInfoView( }, close = close, onSearchClicked = onSearchClicked, - disabled = progressIndicator + deletingItems = deletingItems ) - - if (progressIndicator.value) { - ProgressIndicator(true) - } } } @@ -544,7 +541,7 @@ fun ChatInfoLayout( verifyClicked: () -> Unit, close: () -> Unit, onSearchClicked: () -> Unit, - disabled: State + deletingItems: State ) { val cStats = connStats.value val scrollState = rememberScrollState() @@ -552,7 +549,7 @@ fun ChatInfoLayout( KeyChangeEffect(chat.id) { scope.launch { scrollState.scrollTo(0) } } - ColumnWithScrollBar(Modifier.alpha(if (disabled.value) 0.6f else 1f)) { + ColumnWithScrollBar { Row( Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center @@ -621,15 +618,7 @@ fun ChatInfoLayout( } SectionDividerSpaced(maxBottomPadding = false) - SectionView { - TtlOptions( - chatItemTTL, - enabled = remember { mutableStateOf(true) }, - onSelected = setChatItemTTL, - default = chatModel.chatItemTTL - ) - } - SectionTextFooter(stringResource(MR.strings.chat_ttl_options_footer)) + ChatTTLSection(chatItemTTL, setChatItemTTL, deletingItems) SectionDividerSpaced(maxTopPadding = true, maxBottomPadding = false) val conn = contact.activeConn @@ -1381,6 +1370,7 @@ private fun setChatTTL( withBGApi { try { chatModel.controller.setChatTTL(rhId, chatInfo.chatType, chatInfo.apiId, chatTTL.value) + delay(5000) afterSetChatTTL(rhId, chatInfo, progressIndicator) } catch (e: Exception) { chatTTL.value = previousChatTTL @@ -1450,7 +1440,7 @@ fun PreviewChatInfoLayout() { verifyClicked = {}, close = {}, onSearchClicked = {}, - disabled = remember { mutableStateOf(true) } + deletingItems = remember { mutableStateOf(false) } ) } } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoView.kt index 5f987f8298..622fbec7bd 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupChatInfoView.kt @@ -58,7 +58,7 @@ fun ModalData.GroupChatInfoView(chatModel: ChatModel, rhId: Long?, chatId: Strin val groupInfo = chat.chatInfo.groupInfo val sendReceipts = remember { mutableStateOf(SendReceipts.fromBool(groupInfo.chatSettings.sendRcpts, currentUser.sendRcptsSmallGroups)) } val chatItemTTL = remember(groupInfo.id) { mutableStateOf(if (groupInfo.chatItemTTL != null) ChatItemTTL.fromSeconds(groupInfo.chatItemTTL) else null) } - val progressIndicator = rememberSaveable(groupInfo.id) { mutableStateOf(false) } + val deletingItems = rememberSaveable(groupInfo.id) { mutableStateOf(false) } val scope = rememberCoroutineScope() GroupChatInfoLayout( @@ -79,7 +79,7 @@ fun ModalData.GroupChatInfoView(chatModel: ChatModel, rhId: Long?, chatId: Strin val previousChatTTL = chatItemTTL.value chatItemTTL.value = it - setChatTTLAlert(chat.remoteHostId, chat.chatInfo, chatItemTTL, previousChatTTL, progressIndicator) + setChatTTLAlert(chat.remoteHostId, chat.chatInfo, chatItemTTL, previousChatTTL, deletingItems) }, members = remember { chatModel.groupMembers }.value .filter { it.memberStatus != GroupMemberStatus.MemLeft && it.memberStatus != GroupMemberStatus.MemRemoved } @@ -141,12 +141,8 @@ fun ModalData.GroupChatInfoView(chatModel: ChatModel, rhId: Long?, chatId: Strin ModalManager.end.showModal { GroupLinkView(chatModel, rhId, groupInfo, groupLink, groupLinkMemberRole, onGroupLinkUpdated) } }, onSearchClicked = onSearchClicked, - disabled = progressIndicator + deletingItems = deletingItems ) - - if (progressIndicator.value) { - ProgressIndicator(true) - } } } @@ -323,7 +319,7 @@ fun ModalData.GroupChatInfoLayout( manageGroupLink: () -> Unit, close: () -> Unit = { ModalManager.closeAllModalsEverywhere()}, onSearchClicked: () -> Unit, - disabled: State + deletingItems: State ) { val listState = remember { appBarHandler.listState } val scope = rememberCoroutineScope() @@ -337,7 +333,7 @@ fun ModalData.GroupChatInfoLayout( if (s.isEmpty()) members else members.filter { m -> m.anyNameContains(s) } } } - Box(Modifier.alpha(if (disabled.value) 0.6f else 1f)) { + Box { val oneHandUI = remember { appPrefs.oneHandUI.state } LazyColumnWithScrollBar( state = listState, @@ -419,15 +415,7 @@ fun ModalData.GroupChatInfoLayout( SectionTextFooter(stringResource(footerId)) SectionDividerSpaced(maxTopPadding = true, maxBottomPadding = false) - SectionView { - TtlOptions( - chatItemTTL, - enabled = remember { mutableStateOf(true) }, - onSelected = setChatItemTTL, - default = chatModel.chatItemTTL - ) - } - SectionTextFooter(stringResource(MR.strings.chat_ttl_options_footer)) + ChatTTLSection(chatItemTTL, setChatItemTTL, deletingItems) SectionDividerSpaced(maxTopPadding = true, maxBottomPadding = true) SectionView(title = String.format(generalGetString(MR.strings.group_info_section_title_num_members), members.count() + 1)) { @@ -497,6 +485,24 @@ fun ModalData.GroupChatInfoLayout( } } +@Composable +fun ChatTTLSection(chatItemTTL: State, setChatItemTTL: (ChatItemTTL?) -> Unit, deletingItems: State) { + SectionView { + Box(contentAlignment = Alignment.Center) { + TtlOptions( + chatItemTTL, + enabled = remember { derivedStateOf { !deletingItems.value } }, + onSelected = setChatItemTTL, + default = chatModel.chatItemTTL + ) + if (deletingItems.value) { + ProgressIndicator() + } + } + } + SectionTextFooter(stringResource(MR.strings.chat_ttl_options_footer)) +} + @Composable private fun GroupChatInfoHeader(cInfo: ChatInfo, groupInfo: GroupInfo) { Column( @@ -811,7 +817,7 @@ fun PreviewGroupChatInfoLayout() { onLocalAliasChanged = {}, groupLink = null, scrollToItemId = remember { mutableStateOf(null) }, - addMembers = {}, showMemberInfo = {}, editGroupProfile = {}, addOrEditWelcomeMessage = {}, openPreferences = {}, deleteGroup = {}, clearChat = {}, leaveGroup = {}, manageGroupLink = {}, onSearchClicked = {}, disabled = remember { mutableStateOf(true) } + addMembers = {}, showMemberInfo = {}, editGroupProfile = {}, addOrEditWelcomeMessage = {}, openPreferences = {}, deleteGroup = {}, clearChat = {}, leaveGroup = {}, manageGroupLink = {}, onSearchClicked = {}, deletingItems = remember { mutableStateOf(true) } ) } } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupLinkView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupLinkView.kt index f38c0dc231..987a80e7c0 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupLinkView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupLinkView.kt @@ -198,9 +198,9 @@ private fun RoleSelectionRow(groupInfo: GroupInfo, selectedRole: MutableState