Merge branch 'master' into master-ios

This commit is contained in:
spaced4ndy
2023-05-23 15:55:11 +04:00
7 changed files with 23 additions and 19 deletions
@@ -2573,7 +2573,7 @@ data class TimedMessagesPreference(
): ChatPreference {
companion object {
val ttlValues: List<Int?>
get() = listOf(3600, 8 * 3600, 86400, 7 * 86400, 30 * 86400, null)
get() = listOf(600, 3600, 86400, 7 * 86400, 30 * 86400, 3 * 30 * 86400, null)
}
}
@@ -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,
@@ -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 {
+1 -1
View File
@@ -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]
}
}
+4 -4
View File
@@ -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
+10 -1
View File
@@ -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"
+1 -1
View File
@@ -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]