Filter useless state events on the server side.
This means that presence events appear in the timeline, which is something we DO want.
This commit is contained in:
parent
b0e796ee16
commit
cf05f9dc4a
|
@ -5,12 +5,25 @@ import Scylla.Route exposing (RoomId)
|
|||
import Scylla.Sync exposing (syncResponseDecoder, historyResponseDecoder)
|
||||
import Scylla.Login exposing (loginResponseDecoder, Username, Password)
|
||||
import Scylla.UserData exposing (userDataDecoder, UserData)
|
||||
import Json.Encode exposing (object, string, int, bool)
|
||||
import Url.Builder
|
||||
import Json.Encode exposing (object, string, int, bool, list)
|
||||
import Http exposing (request, emptyBody, jsonBody, fileBody, expectJson, expectWhatever)
|
||||
import File exposing (File, name, mime)
|
||||
import Url.Builder as Builder
|
||||
import Json.Decode
|
||||
|
||||
firstSyncFilter : Json.Decode.Value
|
||||
firstSyncFilter = object
|
||||
[ ("room", object
|
||||
[ ("state", object
|
||||
[ ("types", list string [ "m.room.name" ])
|
||||
])
|
||||
])
|
||||
]
|
||||
|
||||
firstSyncFilterString : String
|
||||
firstSyncFilterString = Json.Encode.encode 0 firstSyncFilter
|
||||
|
||||
fullClientUrl : ApiUrl -> ApiUrl
|
||||
fullClientUrl s = s ++ "/_matrix/client/r0"
|
||||
|
||||
|
@ -22,7 +35,7 @@ firstSync : ApiUrl -> ApiToken -> Cmd Msg
|
|||
firstSync apiUrl token = request
|
||||
{ method = "GET"
|
||||
, headers = authenticatedHeaders token
|
||||
, url = (fullClientUrl apiUrl) ++ "/sync"
|
||||
, url = Url.Builder.crossOrigin (fullClientUrl apiUrl) [ "sync" ] [ Url.Builder.string "filter" firstSyncFilterString ]
|
||||
, body = emptyBody
|
||||
, expect = expectJson ReceiveFirstSyncResponse syncResponseDecoder
|
||||
, timeout = Nothing
|
||||
|
|
|
@ -392,19 +392,11 @@ mergeRooms r1 r2 =
|
|||
}
|
||||
|
||||
mergeSyncResponse : SyncResponse -> SyncResponse -> SyncResponse
|
||||
mergeSyncResponse l r = filterUselessState <|
|
||||
mergeSyncResponse l r =
|
||||
{ r | rooms = mergeMaybe mergeRooms l.rooms r.rooms
|
||||
, accountData = mergeMaybe mergeAccountData l.accountData r.accountData
|
||||
}
|
||||
|
||||
filterUselessState : SyncResponse -> SyncResponse
|
||||
filterUselessState sr =
|
||||
let
|
||||
filterUselessRoomState _ r = { r | state = Maybe.map (\s -> { s | events = Maybe.map (List.filter (((==) "m.room.name") << .type_)) s.events }) r.state }
|
||||
filterUselessRoomsState rs = { rs | join = Maybe.map (Dict.map filterUselessRoomState) rs.join }
|
||||
in
|
||||
{ sr | rooms = Maybe.map (filterUselessRoomsState) sr.rooms }
|
||||
|
||||
appendRoomHistoryResponse : JoinedRoom -> HistoryResponse -> JoinedRoom
|
||||
appendRoomHistoryResponse jr hr =
|
||||
let
|
||||
|
|
Loading…
Reference in New Issue
Block a user