Decode id strings.

This commit is contained in:
Danila Fedorin 2019-03-15 18:01:26 -07:00
parent 1b0ad433b9
commit f2a8acc59c
2 changed files with 6 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import Scylla.Login exposing (loginResponseDecoder, Username, Password)
import Scylla.UserData exposing (userDataDecoder, UserData)
import Url.Builder
import Json.Encode exposing (object, string, int, bool, list)
import Json.Decode as Decode exposing (field)
import Http exposing (request, emptyBody, jsonBody, fileBody, expectJson, expectWhatever)
import File exposing (File, name, mime)
import Url.Builder as Builder
@ -75,7 +76,7 @@ getHistory apiUrl token room prevBatch = request
, tracker = Nothing
}
sendMessage : ApiUrl -> ApiToken -> Int -> RoomId -> (Result Http.Error () -> Msg) -> List (String, Json.Encode.Value) -> Cmd Msg
sendMessage : ApiUrl -> ApiToken -> Int -> RoomId -> (Result Http.Error String -> Msg) -> List (String, Json.Encode.Value) -> Cmd Msg
sendMessage apiUrl token transactionId room msg contents = request
{ method = "PUT"
, headers = authenticatedHeaders token
@ -84,7 +85,7 @@ sendMessage apiUrl token transactionId room msg contents = request
++ "/send/" ++ "m.room.message"
++ "/" ++ (String.fromInt transactionId)
, body = jsonBody <| object contents
, expect = expectWhatever msg
, expect = expectJson msg (field "event_id" Decode.string)
, timeout = Nothing
, tracker = Nothing
}

View File

@ -44,7 +44,7 @@ type Msg =
| ChangeRoute Route -- URL changes
| ChangeRoomText String String -- Change to a room's input text
| SendRoomText String -- Sends a message typed into a given room's input
| SendRoomTextResponse Int (Result Http.Error ()) -- A send message response finished
| SendRoomTextResponse Int (Result Http.Error String) -- A send message response finished
| ViewportAfterMessage (Result Browser.Dom.Error Viewport) -- A message has been received, try scroll (maybe)
| ViewportChangeComplete (Result Browser.Dom.Error ()) -- We're done changing the viewport.
| ReceiveFirstSyncResponse (Result Http.Error SyncResponse) -- HTTP, Sync has finished
@ -63,8 +63,8 @@ type Msg =
| FilesSelected RoomId File (List File)
| ImageUploadComplete RoomId File (Result Http.Error String)
| FileUploadComplete RoomId File (Result Http.Error String)
| SendImageResponse (Result Http.Error ())
| SendFileResponse (Result Http.Error ())
| SendImageResponse (Result Http.Error String)
| SendFileResponse (Result Http.Error String)
| ReceiveMarkdown MarkdownResponse
| DismissError Int
| AttemptReconnect