Save account data value on confirmation by server
parent
75971fec66
commit
290be4e746
|
@ -92,6 +92,15 @@ 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
|
||||
that has been generated by the client.
|
||||
-}
|
||||
|
|
|
@ -28,6 +28,13 @@ accountData key (IRoom room) =
|
|||
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.
|
||||
-}
|
||||
addEvent : IEvent -> IRoom -> IRoom
|
||||
|
|
|
@ -122,7 +122,21 @@ updateWith vaultUpdate ((Vault ({ cred, context } as data)) as vault) =
|
|||
|
||||
-- TODO
|
||||
AccountDataSet input () ->
|
||||
vault
|
||||
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
|
||||
|
||||
-- TODO
|
||||
BanUser input () ->
|
||||
|
|
Loading…
Reference in New Issue