Filter some useless events to improve performance.

This commit is contained in:
Danila Fedorin 2018-12-25 18:01:16 -08:00
parent 3c91be9fb6
commit d0c21cc2fa

View File

@ -392,11 +392,19 @@ mergeRooms r1 r2 =
}
mergeSyncResponse : SyncResponse -> SyncResponse -> SyncResponse
mergeSyncResponse l r =
mergeSyncResponse l r = filterUselessState <|
{ 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