Add ephemeral events to Room
parent
f6a6bb535e
commit
0ded7ab6bd
|
@ -313,6 +313,7 @@ fields :
|
||||||
}
|
}
|
||||||
, room :
|
, room :
|
||||||
{ accountData : Desc
|
{ accountData : Desc
|
||||||
|
, ephemeral : Desc
|
||||||
, events : Desc
|
, events : Desc
|
||||||
, roomId : Desc
|
, roomId : Desc
|
||||||
, state : Desc
|
, state : Desc
|
||||||
|
@ -486,6 +487,9 @@ fields =
|
||||||
, room =
|
, room =
|
||||||
{ accountData =
|
{ accountData =
|
||||||
[ "Room account data tracking the user's private storage about this room." ]
|
[ "Room account data tracking the user's private storage about this room." ]
|
||||||
|
, ephemeral =
|
||||||
|
[ "Ephemeral events that were sent recently in this room."
|
||||||
|
]
|
||||||
, events =
|
, events =
|
||||||
[ "Database containing events that were sent in this room." ]
|
[ "Database containing events that were sent in this room." ]
|
||||||
, roomId =
|
, roomId =
|
||||||
|
|
|
@ -53,6 +53,7 @@ import Internal.Config.Text as Text
|
||||||
import Internal.Filter.Timeline as Filter exposing (Filter)
|
import Internal.Filter.Timeline as Filter exposing (Filter)
|
||||||
import Internal.Tools.Hashdict as Hashdict exposing (Hashdict)
|
import Internal.Tools.Hashdict as Hashdict exposing (Hashdict)
|
||||||
import Internal.Tools.Json as Json
|
import Internal.Tools.Json as Json
|
||||||
|
import Internal.Tools.StrippedEvent as StrippedEvent exposing (StrippedEvent)
|
||||||
import Internal.Values.Event as Event exposing (Event)
|
import Internal.Values.Event as Event exposing (Event)
|
||||||
import Internal.Values.StateManager as StateManager exposing (StateManager)
|
import Internal.Values.StateManager as StateManager exposing (StateManager)
|
||||||
import Internal.Values.Timeline as Timeline exposing (Timeline)
|
import Internal.Values.Timeline as Timeline exposing (Timeline)
|
||||||
|
@ -71,6 +72,7 @@ homeserver.
|
||||||
-}
|
-}
|
||||||
type alias Room =
|
type alias Room =
|
||||||
{ accountData : Dict String Json.Value
|
{ accountData : Dict String Json.Value
|
||||||
|
, ephemeral : List StrippedEvent
|
||||||
, events : Hashdict Event
|
, events : Hashdict Event
|
||||||
, roomId : String
|
, roomId : String
|
||||||
, state : StateManager
|
, state : StateManager
|
||||||
|
@ -86,7 +88,9 @@ type RoomUpdate
|
||||||
| AddSync Batch
|
| AddSync Batch
|
||||||
| Invite User
|
| Invite User
|
||||||
| More (List RoomUpdate)
|
| More (List RoomUpdate)
|
||||||
|
| Optional (Maybe RoomUpdate)
|
||||||
| SetAccountData String Json.Value
|
| SetAccountData String Json.Value
|
||||||
|
| SetEphemeral (List { eventType : String, content : Json.Value })
|
||||||
|
|
||||||
|
|
||||||
{-| Add new events to the Room's event directory + Room's timeline.
|
{-| Add new events to the Room's event directory + Room's timeline.
|
||||||
|
@ -140,7 +144,7 @@ addSync =
|
||||||
-}
|
-}
|
||||||
coder : Json.Coder Room
|
coder : Json.Coder Room
|
||||||
coder =
|
coder =
|
||||||
Json.object5
|
Json.object6
|
||||||
{ name = Text.docs.room.name
|
{ name = Text.docs.room.name
|
||||||
, description = Text.docs.room.description
|
, description = Text.docs.room.description
|
||||||
, init = Room
|
, init = Room
|
||||||
|
@ -154,6 +158,15 @@ coder =
|
||||||
, defaultToString = Json.encode (Json.fastDict Json.value) >> E.encode 0
|
, defaultToString = Json.encode (Json.fastDict Json.value) >> E.encode 0
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
(Json.field.optional.withDefault
|
||||||
|
{ fieldName = "ephemeral"
|
||||||
|
, toField = .ephemeral
|
||||||
|
, description = Text.fields.room.ephemeral
|
||||||
|
, coder = Json.list StrippedEvent.coder
|
||||||
|
, default = ( [], [] )
|
||||||
|
, defaultToString = Json.encode (Json.list StrippedEvent.coder) >> E.encode 0
|
||||||
|
}
|
||||||
|
)
|
||||||
(Json.field.optional.withDefault
|
(Json.field.optional.withDefault
|
||||||
{ fieldName = "events"
|
{ fieldName = "events"
|
||||||
, toField = .events
|
, toField = .events
|
||||||
|
@ -216,6 +229,7 @@ getAccountData key room =
|
||||||
init : String -> Room
|
init : String -> Room
|
||||||
init roomId =
|
init roomId =
|
||||||
{ accountData = Dict.empty
|
{ accountData = Dict.empty
|
||||||
|
, ephemeral = []
|
||||||
, events = Hashdict.empty .eventId
|
, events = Hashdict.empty .eventId
|
||||||
, roomId = roomId
|
, roomId = roomId
|
||||||
, state = StateManager.empty
|
, state = StateManager.empty
|
||||||
|
@ -262,5 +276,14 @@ update ru room =
|
||||||
More items ->
|
More items ->
|
||||||
List.foldl update room items
|
List.foldl update room items
|
||||||
|
|
||||||
|
Optional (Just u) ->
|
||||||
|
update u room
|
||||||
|
|
||||||
|
Optional Nothing ->
|
||||||
|
room
|
||||||
|
|
||||||
SetAccountData key value ->
|
SetAccountData key value ->
|
||||||
setAccountData key value room
|
setAccountData key value room
|
||||||
|
|
||||||
|
SetEphemeral eph ->
|
||||||
|
{ room | ephemeral = eph }
|
||||||
|
|
Loading…
Reference in New Issue