From 360b7be28161d0ece9264cc599c1a4614a624b30 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sat, 7 Sep 2019 17:06:23 -0700 Subject: [PATCH] Change room name func to match user name func --- src/Scylla/Model.elm | 30 +++++++++++++++--------------- src/Scylla/Views.elm | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Scylla/Model.elm b/src/Scylla/Model.elm index 0dd1ad7..55efe5a 100644 --- a/src/Scylla/Model.elm +++ b/src/Scylla/Model.elm @@ -60,25 +60,25 @@ type Msg = | TypingTick Posix -- Tick for updating the typing status | History RoomId -- Load history for a room | ReceiveHistoryResponse RoomId (Result Http.Error HistoryResponse) -- HTTP, receive history - | SendImages RoomId - | SendFiles RoomId - | ImagesSelected RoomId File (List File) - | FilesSelected RoomId File (List File) - | ImageUploadComplete RoomId File (Result Http.Error String) - | FileUploadComplete RoomId File (Result Http.Error String) - | SendImageResponse (Result Http.Error String) - | SendFileResponse (Result Http.Error String) - | ReceiveMarkdown MarkdownResponse - | DismissError Int - | AttemptReconnect - | UpdateSearchText String + | SendImages RoomId -- Image selection triggered + | SendFiles RoomId -- File selection triggered + | ImagesSelected RoomId File (List File) -- Images to send selected + | FilesSelected RoomId File (List File) -- Files to send selected + | ImageUploadComplete RoomId File (Result Http.Error String) -- Image has been uploaded + | FileUploadComplete RoomId File (Result Http.Error String) -- File has been uploaded + | SendImageResponse (Result Http.Error String) -- Server responded to image + | SendFileResponse (Result Http.Error String) -- Server responded to file + | ReceiveMarkdown MarkdownResponse -- Markdown was rendered + | DismissError Int -- User dismisses error + | AttemptReconnect -- User wants to reconnect to server + | UpdateSearchText String -- Change search text in room list displayName : Dict String UserData -> Username -> String displayName ud s = Maybe.withDefault (senderName s) <| Maybe.andThen .displayName <| Dict.get s ud -roomDisplayName : Model -> RoomId -> String -roomDisplayName m rid = - Maybe.withDefault "" <| Dict.get rid m.roomNames +roomDisplayName : Dict RoomId String -> RoomId -> String +roomDisplayName rd rid = + Maybe.withDefault "" <| Dict.get rid rd computeRoomDisplayName : Dict String UserData -> Maybe AccountData -> RoomId -> JoinedRoom -> Maybe String computeRoomDisplayName ud ad rid jr = diff --git a/src/Scylla/Views.elm b/src/Scylla/Views.elm index a92279e..815a888 100644 --- a/src/Scylla/Views.elm +++ b/src/Scylla/Views.elm @@ -112,14 +112,14 @@ homeserverView m hs rs = let roomList = div [ class "rooms-list" ] <| 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 div [ class "homeserver-wrapper" ] [ h3 [] [ text hs ], roomList ] roomListElementView : Model -> RoomId -> JoinedRoom -> Html Msg roomListElementView m rid jr = let - name = roomDisplayName m rid + name = roomDisplayName m.roomNames rid isVisible = m.searchText == "" || (String.contains (String.toLower m.searchText) <| String.toLower name) isCurrentRoom = case currentRoomId m of Nothing -> False @@ -183,7 +183,7 @@ joinedRoomView m roomId jr = ] in 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 , messageInput , typingWrapper