Merge branch 'master' into master-ghc8107

This commit is contained in:
Evgeny Poberezkin 2023-12-27 20:57:25 +00:00
commit 0a6e47dd61
9 changed files with 17 additions and 29 deletions

View File

@ -223,8 +223,8 @@ afterEvaluate {
return this return this
} }
val fileRegex = Regex("MR/../strings.xml$|MR/..-.../strings.xml$|MR/..-../strings.xml$|MR/base/strings.xml$") val fileRegex = Regex("MR/../strings.xml$|MR/..-.../strings.xml$|MR/..-../strings.xml$|MR/base/strings.xml$")
val tree = kotlin.sourceSets["commonMain"].resources.filter { fileRegex.containsMatchIn(it.absolutePath) }.asFileTree val tree = kotlin.sourceSets["commonMain"].resources.filter { fileRegex.containsMatchIn(it.absolutePath.replace("\\", "/")) }.asFileTree
val baseStringsFile = tree.first { it.absolutePath.endsWith("base/strings.xml") } ?: throw Exception("No base/strings.xml found") val baseStringsFile = tree.firstOrNull { it.absolutePath.replace("\\", "/").endsWith("base/strings.xml") } ?: throw Exception("No base/strings.xml found")
val treeList = ArrayList(tree.toList()) val treeList = ArrayList(tree.toList())
treeList.remove(baseStringsFile) treeList.remove(baseStringsFile)
treeList.add(0, baseStringsFile) treeList.add(0, baseStringsFile)

View File

@ -58,7 +58,7 @@ object ChatModel {
val chatItemStatuses = mutableMapOf<Long, CIStatus>() val chatItemStatuses = mutableMapOf<Long, CIStatus>()
val groupMembers = mutableStateListOf<GroupMember>() val groupMembers = mutableStateListOf<GroupMember>()
val terminalItems = mutableStateListOf<TerminalItem>() val terminalItems = mutableStateOf<List<TerminalItem>>(listOf())
val userAddress = mutableStateOf<UserContactLinkRec?>(null) val userAddress = mutableStateOf<UserContactLinkRec?>(null)
// Allows to temporary save servers that are being edited on multiple screens // Allows to temporary save servers that are being edited on multiple screens
val userSMPServersUnsaved = mutableStateOf<(List<ServerCfg>)?>(null) val userSMPServersUnsaved = mutableStateOf<(List<ServerCfg>)?>(null)
@ -620,10 +620,10 @@ object ChatModel {
} }
fun addTerminalItem(item: TerminalItem) { fun addTerminalItem(item: TerminalItem) {
if (terminalItems.size >= 500) { if (terminalItems.value.size >= 500) {
terminalItems.removeAt(0) terminalItems.value = terminalItems.value.subList(1, terminalItems.value.size)
} }
terminalItems.add(item) terminalItems.value += item
} }
val connectedToRemote: Boolean @Composable get() = currentRemoteHost.value != null || remoteCtrlSession.value?.active == true val connectedToRemote: Boolean @Composable get() = currentRemoteHost.value != null || remoteCtrlSession.value?.active == true

View File

@ -34,7 +34,6 @@ fun TerminalView(chatModel: ChatModel, close: () -> Unit) {
close() close()
}) })
TerminalLayout( TerminalLayout(
remember { chatModel.terminalItems },
composeState, composeState,
sendCommand = { sendCommand(chatModel, composeState) }, sendCommand = { sendCommand(chatModel, composeState) },
close close
@ -63,7 +62,6 @@ private fun sendCommand(chatModel: ChatModel, composeState: MutableState<Compose
@Composable @Composable
fun TerminalLayout( fun TerminalLayout(
terminalItems: List<TerminalItem>,
composeState: MutableState<ComposeState>, composeState: MutableState<ComposeState>,
sendCommand: () -> Unit, sendCommand: () -> Unit,
close: () -> Unit close: () -> Unit
@ -111,7 +109,7 @@ fun TerminalLayout(
.fillMaxWidth(), .fillMaxWidth(),
color = MaterialTheme.colors.background color = MaterialTheme.colors.background
) { ) {
TerminalLog(terminalItems) TerminalLog()
} }
} }
} }
@ -120,22 +118,13 @@ fun TerminalLayout(
private var lazyListState = 0 to 0 private var lazyListState = 0 to 0
@Composable @Composable
fun TerminalLog(terminalItems: List<TerminalItem>) { fun TerminalLog() {
val listState = rememberLazyListState(lazyListState.first, lazyListState.second) val listState = rememberLazyListState(lazyListState.first, lazyListState.second)
DisposableEffect(Unit) { DisposableEffect(Unit) {
onDispose { lazyListState = listState.firstVisibleItemIndex to listState.firstVisibleItemScrollOffset } onDispose { lazyListState = listState.firstVisibleItemIndex to listState.firstVisibleItemScrollOffset }
} }
val reversedTerminalItems by remember { val reversedTerminalItems by remember {
derivedStateOf { derivedStateOf { chatModel.terminalItems.value.asReversed() }
// Such logic prevents concurrent modification
val res = ArrayList<TerminalItem>()
var i = 0
while (i < terminalItems.size) {
res.add(terminalItems[i])
i++
}
res.asReversed()
}
} }
val clipboard = LocalClipboardManager.current val clipboard = LocalClipboardManager.current
LazyColumn(state = listState, reverseLayout = true) { LazyColumn(state = listState, reverseLayout = true) {
@ -175,7 +164,6 @@ fun TerminalLog(terminalItems: List<TerminalItem>) {
fun PreviewTerminalLayout() { fun PreviewTerminalLayout() {
SimpleXTheme { SimpleXTheme {
TerminalLayout( TerminalLayout(
terminalItems = TerminalItem.sampleData,
composeState = remember { mutableStateOf(ComposeState(useLinkPreviews = false)) }, composeState = remember { mutableStateOf(ComposeState(useLinkPreviews = false)) },
sendCommand = {}, sendCommand = {},
close = {} close = {}

View File

@ -14,7 +14,7 @@ constraints: zip +disable-bzip2 +disable-zstd
source-repository-package source-repository-package
type: git type: git
location: https://github.com/simplex-chat/simplexmq.git location: https://github.com/simplex-chat/simplexmq.git
tag: 22e193237227ed4d243ec9cac8d8249f757d9601 tag: d0588bd0ac23a459cbfc9a4789633014e91ffa19
source-repository-package source-repository-package
type: git type: git

View File

@ -1,5 +1,5 @@
name: simplex-chat name: simplex-chat
version: 5.4.2.0 version: 5.4.2.1
#synopsis: #synopsis:
#description: #description:
homepage: https://github.com/simplex-chat/simplex-chat#readme homepage: https://github.com/simplex-chat/simplex-chat#readme

View File

@ -1,5 +1,5 @@
{ {
"https://github.com/simplex-chat/simplexmq.git"."22e193237227ed4d243ec9cac8d8249f757d9601" = "01h16jc0g5pqdq56k1n0afl2248ln2d11l662ikl6hdn3p3zab0d"; "https://github.com/simplex-chat/simplexmq.git"."d0588bd0ac23a459cbfc9a4789633014e91ffa19" = "0b17qy74capb0jyli8f3pg1xi4aawhcgpmaz2ykl9g3605png1na";
"https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38"; "https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38";
"https://github.com/simplex-chat/direct-sqlcipher.git"."f814ee68b16a9447fbb467ccc8f29bdd3546bfd9" = "1ql13f4kfwkbaq7nygkxgw84213i0zm7c1a8hwvramayxl38dq5d"; "https://github.com/simplex-chat/direct-sqlcipher.git"."f814ee68b16a9447fbb467ccc8f29bdd3546bfd9" = "1ql13f4kfwkbaq7nygkxgw84213i0zm7c1a8hwvramayxl38dq5d";
"https://github.com/simplex-chat/sqlcipher-simple.git"."a46bd361a19376c5211f1058908fc0ae6bf42446" = "1z0r78d8f0812kxbgsm735qf6xx8lvaz27k1a0b4a2m0sshpd5gl"; "https://github.com/simplex-chat/sqlcipher-simple.git"."a46bd361a19376c5211f1058908fc0ae6bf42446" = "1z0r78d8f0812kxbgsm735qf6xx8lvaz27k1a0b4a2m0sshpd5gl";

View File

@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
name: simplex-chat name: simplex-chat
version: 5.4.2.0 version: 5.4.2.1
category: Web, System, Services, Cryptography category: Web, System, Services, Cryptography
homepage: https://github.com/simplex-chat/simplex-chat#readme homepage: https://github.com/simplex-chat/simplex-chat#readme
author: simplex.chat author: simplex.chat

View File

@ -2855,8 +2855,8 @@ subscribeUserConnections vr onlyNeeded agentBatchSubscribe user@User {userId} =
getContactConns :: m ([ConnId], Map ConnId Contact) getContactConns :: m ([ConnId], Map ConnId Contact)
getContactConns = do getContactConns = do
cts <- withStore_ ("subscribeUserConnections " <> show userId <> ", getUserContacts") getUserContacts cts <- withStore_ ("subscribeUserConnections " <> show userId <> ", getUserContacts") getUserContacts
let connIds = mapMaybe contactConnId (filter contactActive cts) let cts' = mapMaybe (\ct -> (,ct) <$> contactConnId ct) $ filter contactActive cts
pure (connIds, M.fromList $ zip connIds cts) pure (map fst cts', M.fromList cts')
getUserContactLinkConns :: m ([ConnId], Map ConnId UserContact) getUserContactLinkConns :: m ([ConnId], Map ConnId UserContact)
getUserContactLinkConns = do getUserContactLinkConns = do
(cs, ucs) <- unzip <$> withStore_ ("subscribeUserConnections " <> show userId <> ", getUserContactLinks") getUserContactLinks (cs, ucs) <- unzip <$> withStore_ ("subscribeUserConnections " <> show userId <> ", getUserContactLinks") getUserContactLinks

View File

@ -72,11 +72,11 @@ import UnliftIO.Directory (copyFile, createDirectoryIfMissing, doesDirectoryExis
-- when acting as host -- when acting as host
minRemoteCtrlVersion :: AppVersion minRemoteCtrlVersion :: AppVersion
minRemoteCtrlVersion = AppVersion [5, 4, 0, 4] minRemoteCtrlVersion = AppVersion [5, 4, 2, 0]
-- when acting as controller -- when acting as controller
minRemoteHostVersion :: AppVersion minRemoteHostVersion :: AppVersion
minRemoteHostVersion = AppVersion [5, 4, 0, 4] minRemoteHostVersion = AppVersion [5, 4, 2, 0]
currentAppVersion :: AppVersion currentAppVersion :: AppVersion
currentAppVersion = AppVersion SC.version currentAppVersion = AppVersion SC.version