From dc73bb3caf87c6a2010824a67d9c44b716f9f1e2 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Tue, 23 May 2023 14:01:07 +0400 Subject: [PATCH 1/3] mobile: change disappearing messages dropdown choices (#2491) --- .../app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt | 2 +- apps/ios/SimpleXChat/ChatTypes.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt b/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt index ff80579dff..57ff629426 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt @@ -2573,7 +2573,7 @@ data class TimedMessagesPreference( ): ChatPreference { companion object { val ttlValues: List - get() = listOf(3600, 8 * 3600, 86400, 7 * 86400, 30 * 86400, null) + get() = listOf(600, 3600, 86400, 7 * 86400, 30 * 86400, 3 * 30 * 86400, null) } } diff --git a/apps/ios/SimpleXChat/ChatTypes.swift b/apps/ios/SimpleXChat/ChatTypes.swift index 957983e4a4..4b49f7ecfa 100644 --- a/apps/ios/SimpleXChat/ChatTypes.swift +++ b/apps/ios/SimpleXChat/ChatTypes.swift @@ -308,7 +308,7 @@ public struct TimedMessagesPreference: Preference { } public static var ttlValues: [Int?] { - [3600, 8 * 3600, 86400, 7 * 86400, 30 * 86400, nil] + [600, 3600, 86400, 7 * 86400, 30 * 86400, 3 * 30 * 86400, nil] } } From f4861482f130c09600b56e5474866ba2219626ca Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Tue, 23 May 2023 14:31:43 +0400 Subject: [PATCH 2/3] mobile: group welcome message to fill max width (#2480) * mobile: group welcome message to fill max width * not limiting preview height * min height, no scroll --------- Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> --- .../simplex/app/views/chat/group/WelcomeMessageView.kt | 8 ++------ apps/ios/Shared/Views/Chat/Group/GroupWelcomeView.swift | 9 ++++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/WelcomeMessageView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/WelcomeMessageView.kt index 5ae99cd4fa..db3fd4daa1 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/WelcomeMessageView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/WelcomeMessageView.kt @@ -114,12 +114,8 @@ private fun GroupWelcomeLayout( @Composable private fun TextPreview(text: String, linkMode: SimplexLinkMode, markdown: Boolean = true) { - Column( - Modifier.height(140.dp) - ) { - SelectionContainer( - Modifier.verticalScroll(rememberScrollState()) - ) { + Column { + SelectionContainer(Modifier.fillMaxWidth()) { MarkdownText( text, formattedText = if (markdown) remember(text) { parseToMarkdown(text) } else null, diff --git a/apps/ios/Shared/Views/Chat/Group/GroupWelcomeView.swift b/apps/ios/Shared/Views/Chat/Group/GroupWelcomeView.swift index 75873131be..0e47d9dddf 100644 --- a/apps/ios/Shared/Views/Chat/Group/GroupWelcomeView.swift +++ b/apps/ios/Shared/Views/Chat/Group/GroupWelcomeView.swift @@ -53,10 +53,10 @@ struct GroupWelcomeView: View { } private func textPreview() -> some View { - ScrollView { - messageText(welcomeText, parseSimpleXMarkdown(welcomeText), nil) - .allowsHitTesting(false) - } + messageText(welcomeText, parseSimpleXMarkdown(welcomeText), nil) + .allowsHitTesting(false) + .frame(minHeight: 140, alignment: .topLeading) + .frame(maxWidth: .infinity, alignment: .leading) } private func editorView() -> some View { @@ -80,7 +80,6 @@ struct GroupWelcomeView: View { } } else { textPreview() - .frame(height: 140, alignment: .topLeading) } Button { From 9644dcb9b49388a1c74a84ab860237a01ec29937 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Tue, 23 May 2023 15:54:44 +0400 Subject: [PATCH 3/3] core: ArchiveError (#2493) --- src/Simplex/Chat/Archive.hs | 8 ++++---- src/Simplex/Chat/Controller.hs | 11 ++++++++++- src/Simplex/Chat/View.hs | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Simplex/Chat/Archive.hs b/src/Simplex/Chat/Archive.hs index d05fccfcf7..630c057bbe 100644 --- a/src/Simplex/Chat/Archive.hs +++ b/src/Simplex/Chat/Archive.hs @@ -48,7 +48,7 @@ exportArchive cfg@ArchiveConfig {archivePath, disableCompression} = let method = if disableCompression == Just True then Z.Store else Z.Deflate Z.createArchive archivePath $ Z.packDirRecur method Z.mkEntrySelector dir -importArchive :: ChatMonad m => ArchiveConfig -> m [(Maybe String, ChatError)] +importArchive :: ChatMonad m => ArchiveConfig -> m [ArchiveError] importArchive cfg@ArchiveConfig {archivePath} = withTempDir cfg "simplex-chat." $ \dir -> do Z.withArchive archivePath $ Z.unpackInto dir @@ -57,7 +57,7 @@ importArchive cfg@ArchiveConfig {archivePath} = backup agentDb copyFile (dir archiveChatDbFile) chatDb copyFile (dir archiveAgentDbFile) agentDb - copyFiles dir filesPath `catchError` \e -> pure [(Nothing, e)] + copyFiles dir filesPath `catchError` \e -> pure [AEImport e] where backup f = whenM (doesFileExist f) $ copyFile f $ f <> ".bak" copyFiles dir filesPath = do @@ -75,14 +75,14 @@ withTempDir cfg = case parentTempDirectory (cfg :: ArchiveConfig) of Just tmpDir -> withTempDirectory tmpDir _ -> withSystemTempDirectory -copyDirectoryFiles :: ChatMonad m => FilePath -> FilePath -> m [(Maybe String, ChatError)] +copyDirectoryFiles :: ChatMonad m => FilePath -> FilePath -> m [ArchiveError] copyDirectoryFiles fromDir toDir = do createDirectoryIfMissing False toDir fs <- listDirectory fromDir foldM copyFileCatchError [] fs where copyFileCatchError fileErrs f = - (copyDirectoryFile f $> fileErrs) `catchError` \e -> pure ((Just f, e) : fileErrs) + (copyDirectoryFile f $> fileErrs) `catchError` \e -> pure (AEImportFile f e : fileErrs) copyDirectoryFile f = do let fn = takeFileName f f' = fromDir fn diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index 6a73432c10..31f6c42fcd 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -524,7 +524,7 @@ data ChatResponse | CRMessageError {user :: User, severity :: Text, errorMessage :: Text} | CRChatCmdError {user_ :: Maybe User, chatError :: ChatError} | CRChatError {user_ :: Maybe User, chatError :: ChatError} - | CRArchiveImported {fileErrors :: [(Maybe String, ChatError)]} + | CRArchiveImported {archiveErrors :: [ArchiveError]} | CRTimedAction {action :: String, durationMilliseconds :: Int64} deriving (Show, Generic) @@ -869,3 +869,12 @@ unsetActive :: (MonadUnliftIO m, MonadReader ChatController m) => ActiveTo -> m unsetActive a = asks activeTo >>= atomically . (`modifyTVar` unset) where unset a' = if a == a' then ActiveNone else a' + +data ArchiveError + = AEImport {chatError :: ChatError} + | AEImportFile {file :: String, chatError :: ChatError} + deriving (Show, Exception, Generic) + +instance ToJSON ArchiveError where + toJSON = J.genericToJSON . sumTypeJSON $ dropPrefix "AE" + toEncoding = J.genericToEncoding . sumTypeJSON $ dropPrefix "AE" diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index 25a4b55ca8..943488df55 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -248,7 +248,7 @@ responseToView user_ ChatConfig {logLevel, showReactions, testView} liveItems ts CRMessageError u prefix err -> ttyUser u [plain prefix <> ": " <> plain err | prefix == "error" || logLevel <= CLLWarning] CRChatCmdError u e -> ttyUserPrefix' u $ viewChatError logLevel e CRChatError u e -> ttyUser' u $ viewChatError logLevel e - CRArchiveImported fileErrs -> if null fileErrs then ["ok"] else ["archive import file errors: " <> plain (show fileErrs)] + CRArchiveImported archiveErrs -> if null archiveErrs then ["ok"] else ["archive import errors: " <> plain (show archiveErrs)] CRTimedAction _ _ -> [] where ttyUser :: User -> [StyledString] -> [StyledString]