Expose sync function

pull/31/head
Bram 2024-07-09 17:50:48 +02:00
parent 4e378a5f50
commit 005e103389
2 changed files with 15 additions and 4 deletions

View File

@ -63,7 +63,7 @@ sendMessageEvent env data =
-}
sync :
E.Envelope a
-> { timeout : Int, toMsg : Msg -> msg }
-> { toMsg : Msg -> msg }
-> Cmd msg
sync env data =
ITask.run
@ -72,7 +72,7 @@ sync env data =
{ fullState = Nothing
, presence = env.settings.presence
, since = env.context.nextBatch
, timeout = Just data.timeout
, timeout = Just env.settings.syncTime
}
)
(Context.apiFormat env.context)

View File

@ -1,6 +1,6 @@
module Matrix exposing
( Vault, fromUserId, fromUsername
, VaultUpdate, update
, VaultUpdate, update, sync
, addAccessToken, sendMessageEvent
)
@ -24,7 +24,7 @@ support a monolithic public registry. (:
## Keeping the Vault up-to-date
@docs VaultUpdate, update
@docs VaultUpdate, update, sync
## Debugging
@ -141,6 +141,17 @@ sendMessageEvent data =
}
{-| Synchronize the Vault with the Matrix API.
Effectively, this task asks the Matrix API to provide the latest information,
which will be returned as your VaultUpdate.
-}
sync : (VaultUpdate -> msg) -> Vault -> Cmd msg
sync toMsg (Vault vault) =
Api.sync vault { toMsg = Types.VaultUpdate >> toMsg }
{-| Using new VaultUpdate information, update the Vault accordingly.
This allows us to change our perception of the Matrix environment: has anyone