From 1b819fea2c0108b8d8e86937628e76eac0aef41b Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Wed, 14 Feb 2024 08:27:14 -0500 Subject: [PATCH] ThreadView - fix threads getting messed up when there's a post without a body --- src/Component/ThreadView.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Component/ThreadView.hs b/src/Component/ThreadView.hs index 8fb52de..366c569 100644 --- a/src/Component/ThreadView.hs +++ b/src/Component/ThreadView.hs @@ -24,7 +24,7 @@ import Miso , consoleLog ) -import Data.Maybe (catMaybes) +import Data.Text (Text) import Miso.String (toMisoString) import GHCJS.DOM.Types (JSString) @@ -55,13 +55,17 @@ data Interface a = Interface { passAction :: Action -> a } update :: Interface a -> Action -> Model -> Effect a Model update iface (RenderSite s) m = m { site = s } <# do - bodies <- mapM parsePostBody (catMaybes $ map Post.body posts) + bodies <- mapM getBody (map Post.body posts) mapM_ (consoleLog . toMisoString . show) bodies return $ passAction iface $ UpdatePostBodies $ zip posts bodies where + getBody :: Maybe Text -> IO [ PostPart ] + getBody Nothing = return [] + getBody (Just b) = parsePostBody b + posts :: [ Post ] posts = Thread.posts $ head $ Board.threads $ head $ Site.boards s --update (RenderSite s) m = noEff (m { site = s }) @@ -139,7 +143,6 @@ reply m (post, parts) = div_ , div_ ( [ class_ "post reply" - , id_ "reply_477702" ] ++ multi post ) [ intro post