Compare commits
No commits in common. "47a684b7777597424c26b2a72f8e7694c081f0ad" and "63fcb2299871f0538334de1ea4a13a842876a4d8" have entirely different histories.
47a684b777
...
63fcb22998
|
@ -1,6 +1,6 @@
|
|||
module Scylla.Model exposing (..)
|
||||
import Scylla.Api exposing (..)
|
||||
import Scylla.Sync exposing (SyncResponse, HistoryResponse, JoinedRoom, senderName, roomName, roomJoinedUsers)
|
||||
import Scylla.Sync exposing (SyncResponse, HistoryResponse, JoinedRoom, senderName)
|
||||
import Scylla.Login exposing (LoginResponse, Username, Password)
|
||||
import Scylla.UserData exposing (UserData)
|
||||
import Scylla.Route exposing (Route(..), RoomId)
|
||||
|
@ -72,25 +72,6 @@ type Msg =
|
|||
displayName : Model -> Username -> String
|
||||
displayName m s = Maybe.withDefault (senderName s) <| Maybe.andThen .displayName <| Dict.get s m.userData
|
||||
|
||||
roomDisplayName : Model -> JoinedRoom -> String
|
||||
roomDisplayName m jr =
|
||||
let
|
||||
customName = roomName jr
|
||||
roomUsers = List.filter ((/=) m.loginUsername) <| roomJoinedUsers jr
|
||||
singleUserName = if List.length roomUsers == 1 then List.head roomUsers else Nothing
|
||||
singleUserDisplayName = Maybe.andThen
|
||||
(\u -> Maybe.andThen .displayName <| Dict.get u m.userData) singleUserName
|
||||
firstOption d os = case os of
|
||||
[] -> d
|
||||
((Just v)::_) -> v
|
||||
(Nothing::xs) -> firstOption d xs
|
||||
in
|
||||
firstOption "<No Name>"
|
||||
[ customName
|
||||
, singleUserDisplayName
|
||||
, singleUserName
|
||||
]
|
||||
|
||||
roomUrl : String -> String
|
||||
roomUrl s = Url.Builder.absolute [ "room", s ] []
|
||||
|
||||
|
|
|
@ -100,16 +100,21 @@ roomGroups jrs = groupBy (homeserver << Tuple.first) jrs
|
|||
homeserverView : Model -> String -> List (String, JoinedRoom) -> Html Msg
|
||||
homeserverView m hs rs =
|
||||
let
|
||||
roomList = div [ class "rooms-list" ]
|
||||
<| List.map (\(rid, r) -> roomListElementView m rid r)
|
||||
<| List.sortBy (\(rid, r) -> roomDisplayName m r) rs
|
||||
roomList = div [ class "rooms-list" ] <| List.map (\(rid, r) -> roomListElementView m rid r) rs
|
||||
in
|
||||
div [ class "homeserver-wrapper" ] [ h3 [] [ text hs ], roomList ]
|
||||
|
||||
roomListElementView : Model -> String -> JoinedRoom -> Html Msg
|
||||
roomListElementView m s jr =
|
||||
let
|
||||
name = roomDisplayName m jr
|
||||
roomUsers = List.filter ((/=) m.loginUsername) <| roomJoinedUsers jr
|
||||
privateChatName = case (List.length roomUsers) of
|
||||
1 -> Maybe.andThen (\u -> Maybe.andThen .displayName <| Dict.get u m.userData) <| List.head roomUsers
|
||||
_ -> Nothing
|
||||
maybeRoomName = case roomName jr of
|
||||
Just rn -> Just rn
|
||||
Nothing -> privateChatName
|
||||
name = Maybe.withDefault "<No Name>" maybeRoomName
|
||||
in
|
||||
div [ class "room-link-wrapper" ]
|
||||
[ a [ href <| roomUrl s ] [ text name ]
|
||||
|
@ -164,7 +169,7 @@ joinedRoomView m roomId rd =
|
|||
]
|
||||
in
|
||||
div [ class "room-wrapper" ]
|
||||
[ h2 [] [ text <| roomDisplayName m rd.joinedRoom ]
|
||||
[ h2 [] [ text <| Maybe.withDefault "<No Name>" <| roomName rd.joinedRoom ]
|
||||
, messagesWrapper
|
||||
, typingWrapper
|
||||
, messageInput
|
||||
|
|
Loading…
Reference in New Issue
Block a user