From e6257d8e38769bc18b0fd0bc744faeb2425c5861 Mon Sep 17 00:00:00 2001 From: Bram Date: Sat, 25 May 2024 19:47:15 +0200 Subject: [PATCH] Change VaultUpdate to API Backpack --- src/Internal/Api/Main.elm | 57 +++++++++++++++++++++++++++++++++++++++ src/Internal/Api/Task.elm | 4 +-- src/Types.elm | 3 ++- 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 src/Internal/Api/Main.elm diff --git a/src/Internal/Api/Main.elm b/src/Internal/Api/Main.elm new file mode 100644 index 0000000..95b9a3e --- /dev/null +++ b/src/Internal/Api/Main.elm @@ -0,0 +1,57 @@ +module Internal.Api.Main exposing + ( Msg + , sendMessageEvent + ) + +{-| + + +# Main API module + +This module is used as reference for getting + + +## VaultUpdate + +@docs Msg + + +## Actions + +@docs sendMessageEvent + +-} + +import Internal.Api.Task as ITask exposing (Backpack) +import Internal.Tools.Json as Json +import Internal.Values.Context as Context +import Internal.Values.Envelope as E + + +type alias Msg = + Backpack + + +{-| Send a message event. +-} +sendMessageEvent : + E.Envelope a + -> + { content : Json.Value + , eventType : String + , roomId : String + , toMsg : Msg -> msg + , transactionId : String + } + -> Cmd msg +sendMessageEvent env data = + ITask.run + data.toMsg + (ITask.sendMessageEvent + { content = data.content + , eventType = data.eventType + , roomId = data.roomId + , transactionId = data.transactionId + } + ) + (Context.apiFormat env.context) diff --git a/src/Internal/Api/Task.elm b/src/Internal/Api/Task.elm index d19ca59..1a8385d 100644 --- a/src/Internal/Api/Task.elm +++ b/src/Internal/Api/Task.elm @@ -1,5 +1,5 @@ module Internal.Api.Task exposing - ( Task, run + ( Task, run, Backpack , sendMessageEvent ) @@ -18,7 +18,7 @@ up-to-date. ## Use -@docs Task, run +@docs Task, run, Backpack ## Tasks diff --git a/src/Types.elm b/src/Types.elm index b461611..174c180 100644 --- a/src/Types.elm +++ b/src/Types.elm @@ -16,6 +16,7 @@ safely access all exposed data types without risking to create circular imports. -} +import Internal.Api.Main as Api import Internal.Values.Envelope as Envelope import Internal.Values.Event as Event import Internal.Values.Room as Room @@ -50,4 +51,4 @@ type Vault {-| Opaque type for Matrix VaultUpdate -} type VaultUpdate - = VaultUpdate (Envelope.EnvelopeUpdate Vault.VaultUpdate) + = VaultUpdate Api.Msg