diff options
-rw-r--r-- | app/Main.hs | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/app/Main.hs b/app/Main.hs index 53c2521..a58613e 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -93,24 +93,28 @@ component = H.ComponentSpec { initialState, render, - eval = H.mkEval $ H.defaultEval {handleAction, handleQuery, initialize = Nothing} + eval = + H.mkEval $ + H.defaultEval + { handleAction, + handleQuery, + initialize = Nothing + } } where initialState _ = pure testChats - render :: (MonadDOM m, MonadUnliftIO m) => [Chat] -> H.ComponentHTML Action slots m + render :: + (MonadDOM m, MonadUnliftIO m) => + [Chat] -> + H.ComponentHTML Action slots m render chats = HH.div_ $ fmap ( \(index, (Chat chatMessages draft)) -> HH.div_ [ HH.div_ - ( fmap - ( \(Message message) -> - HH.text message - ) - chatMessages - ), + (fmap (\(Message message) -> HH.text message) chatMessages), HH.input [ HP.value draft, HE.onInputValueChange $ Just . (DraftChanged index), @@ -131,10 +135,7 @@ component = modify $ \chats -> fmap ( \(indexOther, chat) -> - if indexOther == index - then - chat {draft = draft} - else chat + if indexOther == index then chat {draft = draft} else chat ) (zip [1 ..] chats) get >>= H.raise @@ -144,11 +145,7 @@ component = ( \(indexOther, chat) -> if indexOther == index then - chat - { chatMessages = - chat.chatMessages - ++ [Message chat.draft] - } + chat {chatMessages = chat.chatMessages ++ [Message chat.draft]} else chat ) (zip [1 ..] chats) |