@@ -13,10 +13,10 @@ import Data.Maybe (Maybe(..), fromMaybe, maybe)
1313import Data.Tuple.Nested ((/\))
1414import Date (prettyDate )
1515import Deku.Attribute ((:=))
16- import Deku.Control (dyn_ ,text ,text_ )
17- import Deku.Core (class Korok ,Domable , insert_ )
16+ import Deku.Control (ezDyn_ ,text ,text_ )
17+ import Deku.Core (class Korok ,Domable )
1818import Deku.DOM as D
19- import Deku.Do (useMemoized ,useRemoval , useState ,useState' )
19+ import Deku.Do (useMemoized ,useState ,useState' )
2020import Deku.Do as Deku
2121import Deku.Listeners (click ,injectElementT )
2222import Deku.Pursx (nut , (~~))
@@ -274,37 +274,32 @@ articleLoaded
274274 , articleHeader: nut $D .h2_ [ text_ title ]
275275 , favoritesCount1: fCount
276276 , favoritesCount2: fCount
277- , commentList: nut $ dyn_D .div
278- ( ({ cu: _, com: _ } <$> currentUser <*> (newComment <|> oneOfMap pure comments)) <#> \{ cu, com }-> Deku .do
279- setRemove /\ remove<- useRemoval
280- let profile = pure (D.Href :=" /#/profile/" <> com.author.username)
281- let
282- common =
283- { body: nut (text_ com.body)
284- , imgsrc: pure (D.Src := com.author.image)
285- , profile1: profile
286- , profile2: profile
287- , username: nut (text_ com.author.username)
288- , date: nut (text_ (prettyDate com.updatedAt))
289- }
290- remove <|>
291- ( pure
292- $ insert_
293- $ maybe (theirComment_ ~~ common)
294- ( \u-> do
295- let
296- deleteAction = click $ puredo
297- launchAff_ $ deleteComment u.token slug com.id
298- setRemove
299-
300- myComment_ ~~ (common`union` { deleteAction })
301- )
302- (case cuof
303- SignedIn u
304- | u.username == com.author.username-> Just u
305- | otherwise-> Nothing
306- SignedOut -> Nothing
307- )
308- )
309- )
277+ , commentList: nut $ ezDyn_D .div $
278+ ({ cu: _, com: _ } <$> currentUser <*> (newComment <|> oneOfMap pure comments)) <#> \{ cu, com } { remove }-> do
279+ let profile = pure (D.Href :=" /#/profile/" <> com.author.username)
280+ let
281+ common =
282+ { body: nut (text_ com.body)
283+ , imgsrc: pure (D.Src := com.author.image)
284+ , profile1: profile
285+ , profile2: profile
286+ , username: nut (text_ com.author.username)
287+ , date: nut (text_ (prettyDate com.updatedAt))
288+ }
289+ maybe (theirComment_ ~~ common)
290+ ( \u-> do
291+ let
292+ deleteAction = click $ puredo
293+ launchAff_ $ deleteComment u.token slug com.id
294+ remove
295+
296+ myComment_ ~~ (common`union` { deleteAction })
297+ )
298+ (case cuof
299+ SignedIn u
300+ | u.username == com.author.username-> Just u
301+ | otherwise-> Nothing
302+ SignedOut -> Nothing
303+
304+ )
310305 }