From 720e6db3345d753eb67d71e7068f6fb8edadf9bc Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sat, 15 Dec 2018 23:36:05 -0800 Subject: [PATCH] Read room state events from timeline, too. --- src/Scylla/Sync.elm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Scylla/Sync.elm b/src/Scylla/Sync.elm index 2ff0e4e..a816ac7 100644 --- a/src/Scylla/Sync.elm +++ b/src/Scylla/Sync.elm @@ -387,11 +387,16 @@ senderName s = roomName : JoinedRoom -> Maybe String roomName jr = let - state = jr.state - nameEvent = findLastEvent (((==) "m.room.name") << .type_) - name e = Result.toMaybe <| Decode.decodeValue (field "name" string) e.content + nameEvent = Maybe.andThen (findLastEvent (((==) "m.room.name") << .type_)) + << Maybe.andThen .events + name c = Result.toMaybe <| Decode.decodeValue (field "name" string) c + maybeStateEvent = nameEvent jr.state + maybeTimelineEvent = nameEvent jr.timeline + realEventContent = case maybeTimelineEvent of + Just te -> Just te.content + _ -> Maybe.map .content maybeStateEvent in - Maybe.andThen name <| Maybe.andThen nameEvent <| Maybe.andThen .events <| state + Maybe.andThen name realEventContent -- Business Logic: Event Extraction notificationText : RoomEvent -> String