Commits

paradoxiology committed 1f4ba28

Code cleanup

Comments (0)

Files changed (2)

src/Navigation.hs

              | Exit
            
            
-data NavigationState = NavigationState { curRState           :: ReadingState,
-                                         backList            :: [ReadingState],
-                                         forwardList         :: [ReadingState],
-                                         userInfo            :: Maybe UserInfo
+data NavigationState = NavigationState { curRState   :: ReadingState,
+                                         backList    :: [ReadingState],
+                                         forwardList :: [ReadingState],
+                                         userInfo    :: Maybe UserInfo
                                          }
                                          
 initialNavState :: NavigationState
 
 
 navigateBack :: NavigationState -> NavigationState
-navigateBack nav@(NavigationState{ curRState = cs, 
-                                   backList = bls,
-                                   forwardList = fls}) = if length bls <= 1
+navigateBack nav@(NavigationState{ curRState = cs,
+                                    backList = bls,
+                                 forwardList = fls}) = if length bls <= 1
                                                           then nav
-                                                          else nav{ curRState = ps,
-                                                                    backList = init bls,
+                                                            else nav{ curRState = ps,
+                                                                       backList = init bls,
                                                                     forwardList = cs : fls}
                                                                where ps = last bls
                                                                
                                       backList = bls,
                                       forwardList = fls}) = if null fls
                                                                 then nav
-                                                                else nav{ curRState = ns,
-                                                                          backList = bls ++ [cs],
+                                                                  else nav{ curRState = ns,
+                                                                             backList = bls ++ [cs],
                                                                           forwardList = tail fls}
                                                                 where ns = head fls
 
                              "r":[]          -> return $ GotoSubreddit ""
                              "g":index:_     -> apply GotoArticle index
                              "open":[]       -> return $ OpenArticleURL 0
-                             "open":arg:_ | isBetween "[" "]" argl  -> return $ OpenCommentURL (between "[" "]" argl)
-                                          | all isDigit arg  -> return $ OpenArticleURL (fromMaybe 0 (maybeRead arg))
+                             "open":arg:_ | isBetween "[" "]" argl -> return $ OpenCommentURL (between "[" "]" argl)
+                                          | all isDigit arg        -> return $ OpenArticleURL (fromMaybe 0 (maybeRead arg))
                                           | otherwise              -> throwError "Invalid article index"
                              "a":index:_     -> return $ OpenArticleDetails (fromMaybe 0 (maybeRead index))
                              "a":[]          -> return $ OpenArticleDetails 0
                                putStrLn (replicate 60 '*') 
                                mapM_ (putDoc . articleToDoc cUTC) articles
                                
+                               
 displayDetailArticle article = do
                                    cUTC <- getCurrentTime
                                    putStrLn (replicate 80 '*')
                                    putDoc $ detailArticleToDoc cUTC article
 
+
 displayComments [] = return ()
 displayComments cs = do 
                          cUTC <- getCurrentTime

src/RedditActions.hs

 loginReddit user passwd = let postBdy = "api_type=json&user=" ++ user ++ "&passwd=" ++ passwd
                               postURL = redditDomain ++ "/api/login/" ++ user in
                                   do
-                                      clearCookies
                                       (_, rspt) <- postRequestURL postURL postBdy
                                       case decode rspt of
                                           Ok userInfo -> return . Just $ userInfo{ userName = user }