diff --git a/src/Internal/Api/Main.elm b/src/Internal/Api/Main.elm index 04011d0..bf9b1ea 100644 --- a/src/Internal/Api/Main.elm +++ b/src/Internal/Api/Main.elm @@ -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) diff --git a/src/Matrix.elm b/src/Matrix.elm index f59136a..64f411f 100644 --- a/src/Matrix.elm +++ b/src/Matrix.elm @@ -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