@@ -57,6 +57,7 @@ data Model = Model
5757 , _websocket :: WebSocket
5858 , _connected :: Bool
5959 , _connections :: [WebSocket ]
60+ , _clearInput :: Bool
6061 , _boxId :: Int
6162 } deriving Eq
6263-----------------------------------------------------------------------------
@@ -72,11 +73,14 @@ websocket = lens _websocket $ \r x -> r { _websocket = x }
7273connected :: Lens Model Bool
7374connected = lens _connected $ \ r x -> r { _connected = x }
7475-----------------------------------------------------------------------------
76+ clearInput :: Lens Model Bool
77+ clearInput = lens _clearInput $ \ r x -> r { _clearInput = x }
78+ -----------------------------------------------------------------------------
7579boxId :: Lens Model Int
7680boxId = lens _boxId $ \ r x -> r { _boxId = x }
7781-----------------------------------------------------------------------------
7882emptyModel :: Int -> Model
79- emptyModel = Model mempty [] emptyWebSocket False []
83+ emptyModel = Model mempty [] emptyWebSocket False [] True
8084-----------------------------------------------------------------------------
8185websocketComponent :: Int -> Component parent Model Action
8286websocketComponent box =
@@ -89,6 +93,7 @@ websocketComponent box =
8993 m <- use msg
9094 unless (MS. null m) $ do
9195 issue (SendMessage m)
96+ clearInput .= True
9297 msg .= " "
9398 io $ do
9499 date <- newDate
@@ -123,7 +128,8 @@ websocketComponent box =
123128 received %= (message : )
124129 OnError errorMessage ->
125130 io_ (consoleError errorMessage)
126- Update input ->
131+ Update input -> do
132+ clearInput .= False
127133 msg .= input
128134 NoOp ->
129135 pure ()
@@ -132,6 +138,7 @@ websocketComponent box =
132138 Disconnect ->
133139 close =<< use websocket
134140 Clear -> do
141+ clearInput .= True
135142 msg .= " "
136143 received .= []
137144-----------------------------------------------------------------------------
@@ -204,6 +211,9 @@ viewModel m =
204211 ] ++
205212 [ disabled_
206213 | not (m ^. connected)
214+ ] ++
215+ [ value_ " "
216+ | m ^. clearInput
207217 ]
208218 , optionalAttrs
209219 button_
0 commit comments