mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
remove debug logs on deletion; android: context menu on contact link (#621)
This commit is contained in:
+10
-47
@@ -376,25 +376,15 @@ processChatCommand = \case
|
||||
ct@Contact {localDisplayName} <- withStore $ \st -> getContact st userId chatId
|
||||
withStore (\st -> getContactGroupNames st userId ct) >>= \case
|
||||
[] -> do
|
||||
liftIO $ putStrLn "### files <- withStore $ \\st -> getContactFiles st userId ct"
|
||||
files <- withStore $ \st -> getContactFiles st userId ct
|
||||
liftIO $ putStrLn "### conns <- withStore $ \\st -> getContactConnections st userId ct"
|
||||
conns <- withStore $ \st -> getContactConnections st userId ct
|
||||
liftIO $ putStrLn "### withChatLock . procCmd $ do"
|
||||
withChatLock . procCmd $ do
|
||||
liftIO $ putStrLn "### cancelFiles user (map (\\(fId, fStatus, _) -> (fId, fStatus)) files)"
|
||||
cancelFiles user (map (\(fId, fStatus, _) -> (fId, fStatus)) files)
|
||||
liftIO $ putStrLn "### withFilesFolder $ \\filesFolder -> do"
|
||||
withFilesFolder $ \filesFolder -> do
|
||||
liftIO $ putStrLn "### deleteFiles filesFolder (map (\\(_, _, fPath) -> fPath) files)"
|
||||
withFilesFolder $ \filesFolder ->
|
||||
deleteFiles filesFolder (map (\(_, _, fPath) -> fPath) files)
|
||||
liftIO $ putStrLn "### withAgent $ \\a -> forM_ conns $ \\conn ->"
|
||||
withAgent $ \a -> forM_ conns $ \conn -> do
|
||||
liftIO $ putStrLn "### deleteConnection a (aConnId conn) `catchError` \\(_ :: AgentErrorType) -> pure ()"
|
||||
withAgent $ \a -> forM_ conns $ \conn ->
|
||||
deleteConnection a (aConnId conn) `catchError` \(_ :: AgentErrorType) -> pure ()
|
||||
liftIO $ putStrLn "### withStore $ \\st -> deleteContact st userId ct"
|
||||
withStore $ \st -> deleteContact st userId ct
|
||||
liftIO $ putStrLn "### unsetActive $ ActiveC localDisplayName"
|
||||
unsetActive $ ActiveC localDisplayName
|
||||
pure $ CRContactDeleted ct
|
||||
gs -> throwChatError $ CEContactGroups ct gs
|
||||
@@ -744,14 +734,11 @@ processChatCommand = \case
|
||||
withFilesFolder :: (FilePath -> m ()) -> m ()
|
||||
withFilesFolder action = asks filesFolder >>= readTVarIO >>= mapM_ action
|
||||
deleteFiles :: FilePath -> [Maybe FilePath] -> m ()
|
||||
deleteFiles filesFolder filePaths = do
|
||||
deleteFiles filesFolder filePaths =
|
||||
forM_ filePaths $ \filePath_ ->
|
||||
forM_ filePath_ $ \filePath -> do
|
||||
let fsFilePath = filesFolder <> "/" <> filePath
|
||||
liftIO $ putStrLn ("in deleteFiles - fsFilePath " <> fsFilePath)
|
||||
liftIO $ putStrLn "removeFile fsFilePath `E.catch` \\(_ :: E.SomeException) ->"
|
||||
removeFile fsFilePath `E.catch` \(_ :: E.SomeException) -> do
|
||||
liftIO $ putStrLn "removePathForcibly fsFilePath `E.catch` \\(_ :: E.SomeException) -> pure ()"
|
||||
removeFile fsFilePath `E.catch` \(_ :: E.SomeException) ->
|
||||
removePathForcibly fsFilePath `E.catch` \(_ :: E.SomeException) -> pure ()
|
||||
cancelFiles :: User -> [(Int64, ACIFileStatus)] -> m ()
|
||||
cancelFiles user@User {userId} files = mapM_ maybeCancelFile files
|
||||
@@ -769,39 +756,26 @@ processChatCommand = \case
|
||||
AFS _ CIFSRcvComplete -> pure ()
|
||||
cancelById :: Int64 -> m ()
|
||||
cancelById fileId = do
|
||||
liftIO $ putStrLn ("cancelById - fileId " <> show fileId)
|
||||
liftIO $ putStrLn "ft <- withStore (\\st -> getFileTransfer st userId fileId)"
|
||||
ft <- withStore (\st -> getFileTransfer st userId fileId)
|
||||
liftIO $ putStrLn "void $ cancelFile user fileId ft"
|
||||
void $ cancelFile user fileId ft
|
||||
cancelFile :: User -> Int64 -> FileTransfer -> m ChatResponse
|
||||
cancelFile user@User {userId} fileId ft =
|
||||
case ft of
|
||||
FTSnd ftm fts -> do
|
||||
liftIO $ putStrLn "cancelFileTransfer CIFSSndCancelled"
|
||||
cancelFileTransfer CIFSSndCancelled
|
||||
liftIO $ putStrLn "forM_ fts $ \\ft' -> cancelSndFileTransfer ft'"
|
||||
forM_ fts $ \ft' -> cancelSndFileTransfer ft'
|
||||
liftIO $ putStrLn "ci <- withStore $ \\st -> getChatItemByFileId st user fileId"
|
||||
ci <- withStore $ \st -> getChatItemByFileId st user fileId
|
||||
liftIO $ putStrLn "pure $ CRSndGroupFileCancelled ci ftm fts"
|
||||
pure $ CRSndGroupFileCancelled ci ftm fts
|
||||
FTRcv ftr -> do
|
||||
liftIO $ putStrLn "cancelFileTransfer CIFSRcvCancelled"
|
||||
cancelFileTransfer CIFSRcvCancelled
|
||||
liftIO $ putStrLn "cancelRcvFileTransfer ftr"
|
||||
cancelRcvFileTransfer ftr
|
||||
liftIO $ putStrLn "pure $ CRRcvFileCancelled ftr"
|
||||
pure $ CRRcvFileCancelled ftr
|
||||
where
|
||||
cancelFileTransfer :: MsgDirectionI d => CIFileStatus d -> m ()
|
||||
cancelFileTransfer ciFileStatus = do
|
||||
liftIO $ putStrLn "unless (fileTransferCancelled ft) $"
|
||||
cancelFileTransfer ciFileStatus =
|
||||
unless (fileTransferCancelled ft) $
|
||||
withStore $ \st -> do
|
||||
liftIO $ putStrLn "updateFileCancelled st userId fileId"
|
||||
updateFileCancelled st userId fileId
|
||||
liftIO $ putStrLn "updateCIFileStatus st userId fileId ciFileStatus"
|
||||
updateCIFileStatus st userId fileId ciFileStatus
|
||||
withCurrentCall :: ContactId -> (UserId -> Contact -> Call -> m (Maybe Call)) -> m ChatResponse
|
||||
withCurrentCall ctId action = withUser $ \User {userId} -> do
|
||||
@@ -1897,36 +1871,25 @@ isFileActive fileId files = do
|
||||
|
||||
cancelRcvFileTransfer :: ChatMonad m => RcvFileTransfer -> m ()
|
||||
cancelRcvFileTransfer ft@RcvFileTransfer {fileId, fileStatus} = do
|
||||
liftIO $ putStrLn "closeFileHandle fileId rcvFiles"
|
||||
closeFileHandle fileId rcvFiles
|
||||
liftIO $ putStrLn "withStore $ \\st -> do"
|
||||
withStore $ \st -> do
|
||||
liftIO $ putStrLn "updateRcvFileStatus st ft FSCancelled"
|
||||
updateRcvFileStatus st ft FSCancelled
|
||||
liftIO $ putStrLn "deleteRcvFileChunks st ft"
|
||||
deleteRcvFileChunks st ft
|
||||
case fileStatus of
|
||||
RFSAccepted RcvFileInfo {agentConnId = AgentConnId acId} -> do
|
||||
liftIO $ putStrLn "withAgent (`deleteConnection` acId)"
|
||||
RFSAccepted RcvFileInfo {agentConnId = AgentConnId acId} ->
|
||||
withAgent (`deleteConnection` acId)
|
||||
RFSConnected RcvFileInfo {agentConnId = AgentConnId acId} -> do
|
||||
liftIO $ putStrLn "withAgent (`deleteConnection` acId)"
|
||||
RFSConnected RcvFileInfo {agentConnId = AgentConnId acId} ->
|
||||
withAgent (`deleteConnection` acId)
|
||||
_ -> pure ()
|
||||
|
||||
cancelSndFileTransfer :: ChatMonad m => SndFileTransfer -> m ()
|
||||
cancelSndFileTransfer ft@SndFileTransfer {agentConnId = AgentConnId acId, fileStatus} = do
|
||||
liftIO $ putStrLn "unless (fileStatus == FSCancelled || fileStatus == FSComplete) $ do"
|
||||
cancelSndFileTransfer ft@SndFileTransfer {agentConnId = AgentConnId acId, fileStatus} =
|
||||
unless (fileStatus == FSCancelled || fileStatus == FSComplete) $ do
|
||||
withStore $ \st -> do
|
||||
liftIO $ putStrLn "updateSndFileStatus st ft FSCancelled"
|
||||
updateSndFileStatus st ft FSCancelled
|
||||
liftIO $ putStrLn "deleteSndFileChunks st ft"
|
||||
deleteSndFileChunks st ft
|
||||
withAgent $ \a -> do
|
||||
liftIO $ putStrLn "void (sendMessage a acId $ smpEncode FileChunkCancel) `catchError` \\_ -> pure ()"
|
||||
void (sendMessage a acId $ smpEncode FileChunkCancel) `catchError` \_ -> pure ()
|
||||
liftIO $ putStrLn "deleteConnection a acId"
|
||||
deleteConnection a acId
|
||||
|
||||
closeFileHandle :: ChatMonad m => Int64 -> (ChatController -> TVar (Map Int64 Handle)) -> m ()
|
||||
@@ -2137,9 +2100,9 @@ withStore ::
|
||||
m a
|
||||
withStore action =
|
||||
asks chatStore
|
||||
-- >>= runExceptT . action
|
||||
>>= runExceptT . action
|
||||
-- use this line instead of above to log query errors
|
||||
>>= (\st -> runExceptT $ action st `E.catch` \(e :: E.SomeException) -> liftIO (print e) >> E.throwIO e)
|
||||
-- >>= (\st -> runExceptT $ action st `E.catch` \(e :: E.SomeException) -> liftIO (print e) >> E.throwIO e)
|
||||
>>= liftEither . first ChatErrorStore
|
||||
|
||||
chatCommandP :: Parser ChatCommand
|
||||
|
||||
@@ -429,9 +429,7 @@ getContactGroupNames st userId Contact {contactId} =
|
||||
|
||||
deleteContact :: MonadUnliftIO m => SQLiteStore -> UserId -> Contact -> m ()
|
||||
deleteContact st userId Contact {contactId, localDisplayName} = do
|
||||
liftIO $ putStrLn "in deleteContact, first liftIO . withTransaction st $ \\db -> do"
|
||||
liftIO . withTransaction st $ \db -> do
|
||||
liftIO $ putStrLn "DB.execute DELETE FROM connections WHERE connection_id IN ..."
|
||||
DB.execute
|
||||
db
|
||||
[sql|
|
||||
@@ -443,15 +441,11 @@ deleteContact st userId Contact {contactId, localDisplayName} = do
|
||||
)
|
||||
|]
|
||||
(userId, contactId)
|
||||
liftIO $ putStrLn "DB.execute db \"DELETE FROM files WHERE user_id = ? AND contact_id = ?\" (userId, contactId)"
|
||||
DB.execute db "DELETE FROM files WHERE user_id = ? AND contact_id = ?" (userId, contactId)
|
||||
liftIO $ putStrLn "in deleteContact, second liftIO . withTransaction st $ \\db -> do"
|
||||
-- in separate transaction to prevent crashes on android (race condition on integrity check?)
|
||||
liftIO . withTransaction st $ \db -> do
|
||||
liftIO $ putStrLn "DB.execute db \"DELETE FROM chat_items WHERE user_id = ? AND contact_id = ?\" (userId, contactId)"
|
||||
DB.execute db "DELETE FROM chat_items WHERE user_id = ? AND contact_id = ?" (userId, contactId)
|
||||
liftIO $ putStrLn "DB.execute db \"DELETE FROM contacts WHERE user_id = ? AND contact_id = ?\" (userId, contactId)"
|
||||
DB.execute db "DELETE FROM contacts WHERE user_id = ? AND contact_id = ?" (userId, contactId)
|
||||
liftIO $ putStrLn "DB.execute db \"DELETE FROM display_names WHERE user_id = ? AND local_display_name = ?\" (userId, localDisplayName)"
|
||||
DB.execute db "DELETE FROM display_names WHERE user_id = ? AND local_display_name = ?" (userId, localDisplayName)
|
||||
|
||||
updateUserProfile :: StoreMonad m => SQLiteStore -> User -> Profile -> m ()
|
||||
|
||||
Reference in New Issue
Block a user