core: support combining store functions in one transaction (#740)
* refactor store functions (WIP - does not compile yet) * update chat * update simplexmq
This commit is contained in:
parent
b2a523c3fe
commit
4bf5125c51
@ -5,7 +5,7 @@ constraints: zip +disable-bzip2 +disable-zstd
|
||||
source-repository-package
|
||||
type: git
|
||||
location: https://github.com/simplex-chat/simplexmq.git
|
||||
tag: b58523d4a29235c29c56a461edb686ed93bc1e89
|
||||
tag: d1db7d6f79b527a689af1807e7d91a92076d2d8c
|
||||
|
||||
source-repository-package
|
||||
type: git
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"https://github.com/simplex-chat/simplexmq.git"."b58523d4a29235c29c56a461edb686ed93bc1e89" = "0k8kmk5dil8dny4xzw6k0c97g0m9ql105x870bvy4sdd2ix23var";
|
||||
"https://github.com/simplex-chat/simplexmq.git"."d1db7d6f79b527a689af1807e7d91a92076d2d8c" = "1zlp925qq8akv8v846g03czn0yb293vdsgd7vs6g0axs4yx6c9ap";
|
||||
"https://github.com/simplex-chat/aeson.git"."3eb66f9a68f103b5f1489382aad89f5712a64db7" = "0kilkx59fl6c3qy3kjczqvm8c3f4n3p0bdk9biyflf51ljnzp4yp";
|
||||
"https://github.com/simplex-chat/haskell-terminal.git"."f708b00009b54890172068f168bf98508ffcd495" = "0zmq7lmfsk8m340g47g5963yba7i88n4afa6z93sg9px5jv1mijj";
|
||||
"https://github.com/zw3rk/android-support.git"."3c3a5ab0b8b137a072c98d3d0937cbdc96918ddb" = "1r6jyxbim3dsvrmakqfyxbd6ms6miaghpbwyl0sr6dzwpgaprz97";
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -85,7 +85,7 @@ defaultMobileConfig =
|
||||
type CJSONString = CString
|
||||
|
||||
getActiveUser_ :: SQLiteStore -> IO (Maybe User)
|
||||
getActiveUser_ st = find activeUser <$> getUsers st
|
||||
getActiveUser_ st = find activeUser <$> withTransaction st getUsers
|
||||
|
||||
chatInit :: String -> IO ChatController
|
||||
chatInit dbFilePrefix = do
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -49,7 +49,7 @@ extra-deps:
|
||||
# - simplexmq-1.0.0@sha256:34b2004728ae396e3ae449cd090ba7410781e2b3cefc59259915f4ca5daa9ea8,8561
|
||||
# - ../simplexmq
|
||||
- github: simplex-chat/simplexmq
|
||||
commit: b58523d4a29235c29c56a461edb686ed93bc1e89
|
||||
commit: d1db7d6f79b527a689af1807e7d91a92076d2d8c
|
||||
# - terminal-0.2.0.0@sha256:de6770ecaae3197c66ac1f0db5a80cf5a5b1d3b64a66a05b50f442de5ad39570,2977
|
||||
- github: simplex-chat/aeson
|
||||
commit: 3eb66f9a68f103b5f1489382aad89f5712a64db7
|
||||
|
@ -100,14 +100,14 @@ createTestChat :: ChatConfig -> ChatOpts -> String -> Profile -> IO TestCC
|
||||
createTestChat cfg opts dbPrefix profile = do
|
||||
let dbFilePrefix = testDBPrefix <> dbPrefix
|
||||
st <- createStore (dbFilePrefix <> "_chat.db") False
|
||||
Right user <- runExceptT $ createUser st profile True
|
||||
Right user <- withTransaction st $ \db -> runExceptT $ createUser db profile True
|
||||
startTestChat_ st cfg opts dbFilePrefix user
|
||||
|
||||
startTestChat :: ChatConfig -> ChatOpts -> String -> IO TestCC
|
||||
startTestChat cfg opts dbPrefix = do
|
||||
let dbFilePrefix = testDBPrefix <> dbPrefix
|
||||
st <- createStore (dbFilePrefix <> "_chat.db") False
|
||||
Just user <- find activeUser <$> getUsers st
|
||||
Just user <- find activeUser <$> withTransaction st getUsers
|
||||
startTestChat_ st cfg opts dbFilePrefix user
|
||||
|
||||
startTestChat_ :: SQLiteStore -> ChatConfig -> ChatOpts -> FilePath -> User -> IO TestCC
|
||||
|
@ -83,7 +83,7 @@ testChatApi :: IO ()
|
||||
testChatApi = withTmpFiles $ do
|
||||
let f = chatStoreFile $ testDBPrefix <> "1"
|
||||
st <- createStore f True
|
||||
Right _ <- runExceptT $ createUser st aliceProfile True
|
||||
Right _ <- withTransaction st $ \db -> runExceptT $ createUser db aliceProfile True
|
||||
cc <- chatInit $ testDBPrefix <> "1"
|
||||
chatSendCmd cc "/u" `shouldReturn` activeUser
|
||||
chatSendCmd cc "/u alice Alice" `shouldReturn` activeUserExists
|
||||
|
Loading…
Reference in New Issue
Block a user