Add id field for sending messages.

The idea is to use this field to dismiss messages only when
a sync response with their id arrives.
This commit is contained in:
Danila Fedorin 2019-03-15 18:01:07 -07:00
parent 7241d112b0
commit 1b0ad433b9
3 changed files with 8 additions and 3 deletions

View File

@ -121,7 +121,7 @@ updateMarkdown m { roomId, text, markdown } =
sendMessageCmd = sendMarkdownMessage m.apiUrl (Maybe.withDefault "" m.token) (m.transactionId + 1) roomId text markdown
newModel =
{ m | transactionId = m.transactionId + 1
, sending = Dict.insert (m.transactionId + 1) (roomId, TextMessage text) m.sending
, sending = Dict.insert (m.transactionId + 1) (roomId, { body = TextMessage text, id = Nothing }) m.sending
}
in
(newModel, Cmd.batch [ storeValueCmd, sendMessageCmd, requestScrollCmd ])

View File

@ -2,7 +2,12 @@ module Scylla.Messages exposing (..)
import Scylla.Sync exposing (RoomEvent)
import Scylla.Login exposing (Username)
type SendingMessage = TextMessage String
type SendingMessageBody = TextMessage String
type alias SendingMessage =
{ body : SendingMessageBody
, id : Maybe String
}
type Message =
Sending SendingMessage

View File

@ -213,7 +213,7 @@ messageView m msg = case msg of
Received re -> roomEventView m re
sendingMessageView : Model -> SendingMessage -> Html Msg
sendingMessageView m msg = case msg of
sendingMessageView m msg = case msg.body of
TextMessage t -> text t
roomEventView : Model -> RoomEvent -> Maybe (Html Msg)