Read room state events from timeline, too.

This commit is contained in:
Danila Fedorin 2018-12-15 23:36:05 -08:00
parent 983592d520
commit 720e6db334

View File

@ -387,11 +387,16 @@ senderName s =
roomName : JoinedRoom -> Maybe String roomName : JoinedRoom -> Maybe String
roomName jr = roomName jr =
let let
state = jr.state nameEvent = Maybe.andThen (findLastEvent (((==) "m.room.name") << .type_))
nameEvent = findLastEvent (((==) "m.room.name") << .type_) << Maybe.andThen .events
name e = Result.toMaybe <| Decode.decodeValue (field "name" string) e.content 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 in
Maybe.andThen name <| Maybe.andThen nameEvent <| Maybe.andThen .events <| state Maybe.andThen name realEventContent
-- Business Logic: Event Extraction -- Business Logic: Event Extraction
notificationText : RoomEvent -> String notificationText : RoomEvent -> String