Compare commits

..

No commits in common. "7122d9e56785aa9fce78ddaf7996941bf032bea8" and "f395259137f639cc5401ea63690e9f4957851a33" have entirely different histories.

2 changed files with 33 additions and 34 deletions

View File

@ -328,10 +328,10 @@ mergeEvents : List Event -> List Event -> List Event
mergeEvents l1 l2 = l1 ++ l2
mergeStateEvents : List StateEvent -> List StateEvent -> List StateEvent
mergeStateEvents l1 l2 = uniqueBy .eventId <| l1 ++ l2
mergeStateEvents l1 l2 = l1 ++ l2
mergeRoomEvents : List RoomEvent -> List RoomEvent -> List RoomEvent
mergeRoomEvents l1 l2 = uniqueBy .eventId <| l1 ++ l2
mergeRoomEvents l1 l2 = l1 ++ l2
mergeStrippedStates : List StrippedState -> List StrippedState -> List StrippedState
mergeStrippedStates l1 l2 = l1 ++ l2

View File

@ -6,7 +6,6 @@ import Scylla.Fnv as Fnv
import Scylla.Room exposing (..)
import Scylla.Messages exposing (..)
import Scylla.Login exposing (Username)
import Scylla.UserData exposing (UserData)
import Scylla.Http exposing (fullMediaUrl)
import Scylla.Api exposing (ApiUrl)
import Html.Parser
@ -160,7 +159,7 @@ loginView m = div [ class "login-wrapper" ]
joinedRoomView : Model -> RoomId -> RoomData -> Html Msg
joinedRoomView m roomId rd =
let
renderedMessages = List.map (userMessagesView m.userData m.apiUrl) <| mergeMessages m.loginUsername <| extractMessages rd
renderedMessages = List.map (userMessagesView m) <| mergeMessages m.loginUsername <| extractMessages rd
messagesWrapper = messagesWrapperView m roomId renderedMessages
typing = List.map (displayName m.userData) <| roomTypingUsers rd.joinedRoom
typingText = String.join ", " typing
@ -214,43 +213,43 @@ messagesWrapperView m rid es = div [ class "messages-wrapper", id "messages-wrap
, table [ class "messages-table" ] es
]
senderView : Dict String UserData -> Username -> Html Msg
senderView ud s =
span [ style "color" <| stringColor s, class "sender-wrapper" ] [ text <| displayName ud s ]
senderView : Model -> Username -> Html Msg
senderView m s =
span [ style "color" <| stringColor s, class "sender-wrapper" ] [ text <| displayName m.userData s ]
userMessagesView : Dict String UserData -> ApiUrl -> (Username, List Message) -> Html Msg
userMessagesView ud apiUrl (u, ms) =
userMessagesView : Model -> (Username, List Message) -> Html Msg
userMessagesView m (u, ms) =
let
wrap h = div [ class "message" ] [ h ]
in
tr []
[ td [] [ senderView ud u ]
, td [] <| List.map wrap <| List.filterMap (messageView apiUrl) ms
[ td [] [ senderView m u ]
, td [] <| List.map wrap <| List.filterMap (messageView m) ms
]
messageView : ApiUrl -> Message -> Maybe (Html Msg)
messageView apiUrl msg = case msg of
Sending t -> Just <| sendingMessageView t
Received re -> roomEventView apiUrl re
messageView : Model -> Message -> Maybe (Html Msg)
messageView m msg = case msg of
Sending t -> Just <| sendingMessageView m t
Received re -> roomEventView m re
sendingMessageView : SendingMessage -> Html Msg
sendingMessageView msg = case msg.body of
sendingMessageView : Model -> SendingMessage -> Html Msg
sendingMessageView m msg = case msg.body of
TextMessage t -> span [ class "sending"] [ text t ]
roomEventView : ApiUrl -> RoomEvent -> Maybe (Html Msg)
roomEventView apiUrl re =
roomEventView : Model -> RoomEvent -> Maybe (Html Msg)
roomEventView m re =
let
msgtype = Decode.decodeValue (Decode.field "msgtype" Decode.string) re.content
in
case msgtype of
Ok "m.text" -> roomEventTextView re
Ok "m.image" -> roomEventImageView apiUrl re
Ok "m.file" -> roomEventFileView apiUrl re
Ok "m.video" -> roomEventVideoView apiUrl re
Ok "m.text" -> roomEventTextView m re
Ok "m.image" -> roomEventImageView m re
Ok "m.file" -> roomEventFileView m re
Ok "m.video" -> roomEventVideoView m re
_ -> Nothing
roomEventTextView : RoomEvent -> Maybe (Html Msg)
roomEventTextView re =
roomEventTextView : Model -> RoomEvent -> Maybe (Html Msg)
roomEventTextView m re =
let
body = Decode.decodeValue (Decode.field "body" Decode.string) re.content
customHtml = Maybe.map Html.Parser.Util.toVirtualDom
@ -262,27 +261,27 @@ roomEventTextView re =
Just c -> Just <| div [] c
Nothing -> Maybe.map (p [] << List.singleton << text) <| Result.toMaybe body
roomEventImageView : ApiUrl -> RoomEvent -> Maybe (Html Msg)
roomEventImageView apiUrl re =
roomEventImageView : Model -> RoomEvent -> Maybe (Html Msg)
roomEventImageView m re =
let
body = Decode.decodeValue (Decode.field "url" Decode.string) re.content
in
Maybe.map (\s -> img [ class "message-image", src s ] [])
<| Maybe.map (contentRepositoryDownloadUrl apiUrl)
<| Maybe.map (contentRepositoryDownloadUrl m.apiUrl)
<| Result.toMaybe body
roomEventFileView : ApiUrl -> RoomEvent -> Maybe (Html Msg)
roomEventFileView apiUrl re =
roomEventFileView : Model -> RoomEvent -> Maybe (Html Msg)
roomEventFileView m re =
let
decoder = Decode.map2 (\l r -> (l, r)) (Decode.field "url" Decode.string) (Decode.field "body" Decode.string)
fileData = Decode.decodeValue decoder re.content
in
Maybe.map (\(url, name) -> a [ href url, class "file-wrapper" ] [ iconView "file", text name ])
<| Maybe.map (\(url, name) -> (contentRepositoryDownloadUrl apiUrl url, name))
<| Maybe.map (\(url, name) -> (contentRepositoryDownloadUrl m.apiUrl url, name))
<| Result.toMaybe fileData
roomEventVideoView : ApiUrl -> RoomEvent -> Maybe (Html Msg)
roomEventVideoView apiUrl re =
roomEventVideoView : Model -> RoomEvent -> Maybe (Html Msg)
roomEventVideoView m re =
let
decoder = Decode.map2 (\l r -> (l, r))
(Decode.field "url" Decode.string)
@ -290,5 +289,5 @@ roomEventVideoView apiUrl re =
videoData = Decode.decodeValue decoder re.content
in
Maybe.map (\(url, t) -> video [ controls True ] [ source [ src url, type_ t ] [] ])
<| Maybe.map (\(url, type_) -> (contentRepositoryDownloadUrl apiUrl url, type_))
<| Maybe.map (\(url, type_) -> (contentRepositoryDownloadUrl m.apiUrl url, type_))
<| Result.toMaybe videoData