Add file buttons and messages (currently do nothing)

This commit is contained in:
Danila Fedorin 2018-12-20 17:03:26 -08:00
parent 2cdfc45a93
commit 98be6ed061
4 changed files with 12 additions and 1 deletions

View File

@ -9,6 +9,7 @@
"NoRedInk/elm-json-decode-pipeline": "1.0.0",
"elm/browser": "1.0.1",
"elm/core": "1.0.2",
"elm/file": "1.0.1",
"elm/html": "1.0.0",
"elm/http": "2.0.0",
"elm/json": "1.1.2",
@ -18,7 +19,6 @@
},
"indirect": {
"elm/bytes": "1.0.7",
"elm/file": "1.0.1",
"elm/virtual-dom": "1.0.2"
}
},

View File

@ -80,6 +80,10 @@ update msg model = case msg of
TypingTick _ -> updateTypingTick model
History r -> updateHistory model r
ReceiveHistoryResponse r hr -> updateHistoryResponse model r hr
SendImages rid -> (model, Cmd.none)
SendFiles rid -> (model, Cmd.none)
ImagesSelected rid f fs -> (model, Cmd.none)
FilesSelected rid f fs -> (model, Cmd.none)
updateHistoryResponse : Model -> RoomId -> Result Http.Error HistoryResponse -> (Model, Cmd Msg)
updateHistoryResponse m r hr =

View File

@ -10,6 +10,7 @@ import Browser.Dom exposing (Viewport)
import Url.Builder
import Dict exposing (Dict)
import Time exposing (Posix)
import File exposing (File)
import Json.Decode
import Browser
import Http
@ -52,6 +53,10 @@ 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)
displayName : Model -> Username -> String
displayName m s = Maybe.withDefault (senderName s) <| Maybe.andThen .displayName <| Dict.get s m.userData

View File

@ -129,6 +129,8 @@ joinedRoomView m roomId jr =
, onEnterKey <| SendRoomText roomId
, value <| Maybe.withDefault "" <| Dict.get roomId m.roomText
] []
, button [ onClick <| SendFiles roomId ] [ iconView "file" ]
, button [ onClick <| SendImages roomId ] [ iconView "image" ]
, button [ onClick <| SendRoomText roomId ] [ iconView "send" ]
]
in