From d0c21cc2facb625b88bab75e7784e816d3238d0e Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 25 Dec 2018 18:01:16 -0800 Subject: [PATCH] Filter some useless events to improve performance. --- src/Scylla/Sync.elm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Scylla/Sync.elm b/src/Scylla/Sync.elm index c4e5c98..10b75b2 100644 --- a/src/Scylla/Sync.elm +++ b/src/Scylla/Sync.elm @@ -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