Skip to content

Commit

Permalink
Remove irrelevant useEffect and spies
Browse files Browse the repository at this point in the history
  • Loading branch information
frasermince committed Feb 24, 2020
1 parent d97791b commit b4cb519
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/Reader.purs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import Record.Builder (build, insert, modify, Builder)
import AsyncStorage (getItem, setItem)
import Data.Tuple (fst)
import BottomContent as BottomContent
import Debug.Trace (spy)
import Foreign.Object (Object)
import Debug.Trace (spy)

type VisibleLocation = {start :: {percentage :: Int, cfi :: String}}

Expand Down Expand Up @@ -185,13 +185,8 @@ useRenditionData showBars setShowBars visibleLocation = React.do
morphology /\ setMorphology <- useState $ (Nothing :: Maybe (Object String))
language /\ setLanguage <- useState $ (Nothing :: Maybe String)
chapterTitle <- useState $ (Nothing :: Maybe String)
useEffect visibleLocation $ do
spy "HERE" (setHighlightedContent \_ -> Nothing)
spy "HERE" (setTranslation \_ -> Nothing)
spy "HERE" (setMorphology \_ -> Nothing)
pure mempty
useEffect highlightedContent $ do
launchAff_ $ mutateAndChangeState mutationFn (spy "***H" highlightedContent) (spy "***L" language) setShowBars setTranslation
launchAff_ $ mutateAndChangeState mutationFn highlightedContent language setShowBars setTranslation
pure mempty


Expand All @@ -207,12 +202,12 @@ useRenditionData showBars setShowBars visibleLocation = React.do
where
mutateAndChangeState mutationFn (Just highlightedContent) (Just language) setShowBars setTranslation = do
let payload = { variables: { input: {snippet: highlightedContent.text, language: language} } }
result <- try $ spy "MUTATE RESULT" $ mutationFn $ payload
result <- try $ mutationFn payload
case result of
Left err -> pure unit
Right r -> do
liftEffect $ setShowBars \_ -> spy "***NOT HERE" false
liftEffect $ setTranslation \_ -> Just $ (spy "result" r).translate.translation
liftEffect $ setShowBars \_ -> false
liftEffect $ setTranslation \_ -> Just r.translate.translation

mutateAndChangeState _ _ _ _ setTranslation = do
liftEffect $ setTranslation \_ -> Nothing
Expand Down

0 comments on commit b4cb519

Please sign in to comment.