Save account data value on confirmation by server

pull/1/head
Bram van den Heuvel 2023-04-06 14:17:17 +02:00
parent 75971fec66
commit 290be4e746
3 changed files with 31 additions and 1 deletions

View File

@ -92,6 +92,15 @@ accountData key =
withoutCredentials >> Internal.accountData key withoutCredentials >> Internal.accountData key
{-| Add account data to the room.
-}
addAccountData : String -> E.Value -> Room -> Room
addAccountData eventType content (Room { room, context }) =
room
|> Internal.addAccountData eventType content
|> withCredentials context
{-| Adds an internal event to the `Room`. An internal event is a custom event {-| Adds an internal event to the `Room`. An internal event is a custom event
that has been generated by the client. that has been generated by the client.
-} -}

View File

@ -28,6 +28,13 @@ accountData key (IRoom room) =
Dict.get key room.accountData Dict.get key room.accountData
{-| Add new account data to the room.
-}
addAccountData : String -> E.Value -> IRoom -> IRoom
addAccountData eventType content (IRoom room) =
IRoom { room | accountData = Dict.insert eventType content room.accountData }
{-| Add the data of a single event to the hashdict of events. {-| Add the data of a single event to the hashdict of events.
-} -}
addEvent : IEvent -> IRoom -> IRoom addEvent : IEvent -> IRoom -> IRoom

View File

@ -122,6 +122,20 @@ updateWith vaultUpdate ((Vault ({ cred, context } as data)) as vault) =
-- TODO -- TODO
AccountDataSet input () -> AccountDataSet input () ->
case input.roomId of
Just rId ->
case getRoomById rId vault of
Just room ->
room
|> Room.addAccountData input.eventType input.content
|> insertRoom
|> (|>) vault
Nothing ->
vault
-- TODO: Add global account data
Nothing ->
vault vault
-- TODO -- TODO