Change room name func to match user name func

This commit is contained in:
Danila Fedorin 2019-09-07 17:06:23 -07:00
parent 06799194e4
commit 360b7be281
2 changed files with 18 additions and 18 deletions

View File

@ -60,25 +60,25 @@ type Msg =
| TypingTick Posix -- Tick for updating the typing status | TypingTick Posix -- Tick for updating the typing status
| History RoomId -- Load history for a room | History RoomId -- Load history for a room
| ReceiveHistoryResponse RoomId (Result Http.Error HistoryResponse) -- HTTP, receive history | ReceiveHistoryResponse RoomId (Result Http.Error HistoryResponse) -- HTTP, receive history
| SendImages RoomId | SendImages RoomId -- Image selection triggered
| SendFiles RoomId | SendFiles RoomId -- File selection triggered
| ImagesSelected RoomId File (List File) | ImagesSelected RoomId File (List File) -- Images to send selected
| FilesSelected RoomId File (List File) | FilesSelected RoomId File (List File) -- Files to send selected
| ImageUploadComplete RoomId File (Result Http.Error String) | ImageUploadComplete RoomId File (Result Http.Error String) -- Image has been uploaded
| FileUploadComplete RoomId File (Result Http.Error String) | FileUploadComplete RoomId File (Result Http.Error String) -- File has been uploaded
| SendImageResponse (Result Http.Error String) | SendImageResponse (Result Http.Error String) -- Server responded to image
| SendFileResponse (Result Http.Error String) | SendFileResponse (Result Http.Error String) -- Server responded to file
| ReceiveMarkdown MarkdownResponse | ReceiveMarkdown MarkdownResponse -- Markdown was rendered
| DismissError Int | DismissError Int -- User dismisses error
| AttemptReconnect | AttemptReconnect -- User wants to reconnect to server
| UpdateSearchText String | UpdateSearchText String -- Change search text in room list
displayName : Dict String UserData -> Username -> String displayName : Dict String UserData -> Username -> String
displayName ud s = Maybe.withDefault (senderName s) <| Maybe.andThen .displayName <| Dict.get s ud displayName ud s = Maybe.withDefault (senderName s) <| Maybe.andThen .displayName <| Dict.get s ud
roomDisplayName : Model -> RoomId -> String roomDisplayName : Dict RoomId String -> RoomId -> String
roomDisplayName m rid = roomDisplayName rd rid =
Maybe.withDefault "<No Name>" <| Dict.get rid m.roomNames Maybe.withDefault "<No Name>" <| Dict.get rid rd
computeRoomDisplayName : Dict String UserData -> Maybe AccountData -> RoomId -> JoinedRoom -> Maybe String computeRoomDisplayName : Dict String UserData -> Maybe AccountData -> RoomId -> JoinedRoom -> Maybe String
computeRoomDisplayName ud ad rid jr = computeRoomDisplayName ud ad rid jr =

View File

@ -112,14 +112,14 @@ homeserverView m hs rs =
let let
roomList = div [ class "rooms-list" ] roomList = div [ class "rooms-list" ]
<| List.map (\(rid, r) -> roomListElementView m rid r) <| List.map (\(rid, r) -> roomListElementView m rid r)
<| List.sortBy (\(rid, r) -> roomDisplayName m rid) rs <| List.sortBy (\(rid, r) -> roomDisplayName m.roomNames rid) rs
in in
div [ class "homeserver-wrapper" ] [ h3 [] [ text hs ], roomList ] div [ class "homeserver-wrapper" ] [ h3 [] [ text hs ], roomList ]
roomListElementView : Model -> RoomId -> JoinedRoom -> Html Msg roomListElementView : Model -> RoomId -> JoinedRoom -> Html Msg
roomListElementView m rid jr = roomListElementView m rid jr =
let let
name = roomDisplayName m rid name = roomDisplayName m.roomNames rid
isVisible = m.searchText == "" || (String.contains (String.toLower m.searchText) <| String.toLower name) isVisible = m.searchText == "" || (String.contains (String.toLower m.searchText) <| String.toLower name)
isCurrentRoom = case currentRoomId m of isCurrentRoom = case currentRoomId m of
Nothing -> False Nothing -> False
@ -183,7 +183,7 @@ joinedRoomView m roomId jr =
] ]
in in
div [ class "room-wrapper" ] div [ class "room-wrapper" ]
[ h2 [] [ text <| roomDisplayName m roomId ] [ h2 [] [ text <| roomDisplayName m.roomNames roomId ]
, lazy6 lazyMessagesView m.userData roomId jr m.apiUrl m.loginUsername m.sending , lazy6 lazyMessagesView m.userData roomId jr m.apiUrl m.loginUsername m.sending
, messageInput , messageInput
, typingWrapper , typingWrapper