mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-14 14:45:33 +00:00
only disable ttl
This commit is contained in:
+9
-19
@@ -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<Boolean>
|
||||
deletingItems: State<Boolean>
|
||||
) {
|
||||
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) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+25
-19
@@ -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<Boolean>
|
||||
deletingItems: State<Boolean>
|
||||
) {
|
||||
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<ChatItemTTL?>, setChatItemTTL: (ChatItemTTL?) -> Unit, deletingItems: State<Boolean>) {
|
||||
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) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -198,9 +198,9 @@ private fun RoleSelectionRow(groupInfo: GroupInfo, selectedRole: MutableState<Gr
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ProgressIndicator(disableInteractions: Boolean = false) {
|
||||
fun ProgressIndicator() {
|
||||
Box(
|
||||
Modifier.fillMaxSize().then(if (disableInteractions) Modifier.clickable(enabled = false, onClick = {}) else Modifier),
|
||||
Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
CircularProgressIndicator(
|
||||
|
||||
Reference in New Issue
Block a user