Decode id strings.
This commit is contained in:
parent
1b0ad433b9
commit
f2a8acc59c
|
@ -7,6 +7,7 @@ import Scylla.Login exposing (loginResponseDecoder, Username, Password)
|
||||||
import Scylla.UserData exposing (userDataDecoder, UserData)
|
import Scylla.UserData exposing (userDataDecoder, UserData)
|
||||||
import Url.Builder
|
import Url.Builder
|
||||||
import Json.Encode exposing (object, string, int, bool, list)
|
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 Http exposing (request, emptyBody, jsonBody, fileBody, expectJson, expectWhatever)
|
||||||
import File exposing (File, name, mime)
|
import File exposing (File, name, mime)
|
||||||
import Url.Builder as Builder
|
import Url.Builder as Builder
|
||||||
|
@ -75,7 +76,7 @@ getHistory apiUrl token room prevBatch = request
|
||||||
, tracker = Nothing
|
, 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
|
sendMessage apiUrl token transactionId room msg contents = request
|
||||||
{ method = "PUT"
|
{ method = "PUT"
|
||||||
, headers = authenticatedHeaders token
|
, headers = authenticatedHeaders token
|
||||||
|
@ -84,7 +85,7 @@ sendMessage apiUrl token transactionId room msg contents = request
|
||||||
++ "/send/" ++ "m.room.message"
|
++ "/send/" ++ "m.room.message"
|
||||||
++ "/" ++ (String.fromInt transactionId)
|
++ "/" ++ (String.fromInt transactionId)
|
||||||
, body = jsonBody <| object contents
|
, body = jsonBody <| object contents
|
||||||
, expect = expectWhatever msg
|
, expect = expectJson msg (field "event_id" Decode.string)
|
||||||
, timeout = Nothing
|
, timeout = Nothing
|
||||||
, tracker = Nothing
|
, tracker = Nothing
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ type Msg =
|
||||||
| ChangeRoute Route -- URL changes
|
| ChangeRoute Route -- URL changes
|
||||||
| ChangeRoomText String String -- Change to a room's input text
|
| ChangeRoomText String String -- Change to a room's input text
|
||||||
| SendRoomText String -- Sends a message typed into a given room's input
|
| 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)
|
| 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.
|
| ViewportChangeComplete (Result Browser.Dom.Error ()) -- We're done changing the viewport.
|
||||||
| ReceiveFirstSyncResponse (Result Http.Error SyncResponse) -- HTTP, Sync has finished
|
| ReceiveFirstSyncResponse (Result Http.Error SyncResponse) -- HTTP, Sync has finished
|
||||||
|
@ -63,8 +63,8 @@ type Msg =
|
||||||
| FilesSelected RoomId File (List File)
|
| FilesSelected RoomId File (List File)
|
||||||
| ImageUploadComplete RoomId File (Result Http.Error String)
|
| ImageUploadComplete RoomId File (Result Http.Error String)
|
||||||
| FileUploadComplete RoomId File (Result Http.Error String)
|
| FileUploadComplete RoomId File (Result Http.Error String)
|
||||||
| SendImageResponse (Result Http.Error ())
|
| SendImageResponse (Result Http.Error String)
|
||||||
| SendFileResponse (Result Http.Error ())
|
| SendFileResponse (Result Http.Error String)
|
||||||
| ReceiveMarkdown MarkdownResponse
|
| ReceiveMarkdown MarkdownResponse
|
||||||
| DismissError Int
|
| DismissError Int
|
||||||
| AttemptReconnect
|
| AttemptReconnect
|
||||||
|
|
Loading…
Reference in New Issue
Block a user