diff --git a/package.yaml b/package.yaml index 47d1601..c604774 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: toodles -version: 1.0.1 +version: 1.0.2 github: "aviaviavi/toodles" license: MIT author: "Avi Press" diff --git a/src/Parse.hs b/src/Parse.hs index 497602f..393f13b 100644 --- a/src/Parse.hs +++ b/src/Parse.hs @@ -77,7 +77,7 @@ integer = lexeme $ L.signed space L.decimal parseAssignee :: Parser String parseAssignee = many (noneOf [')', '|', '=']) --- TODO(avi|p=3|#cleanup) - fix and type this better +-- TODO (avi|p=3|#cleanup) - fix and type this better parseDetails :: Text -> (Maybe Text, Maybe Text, [(Text, Text)], [Text]) parseDetails toParse = let dataTokens = T.splitOn "|" toParse diff --git a/src/Server.hs b/src/Server.hs index b005d72..ac947f1 100644 --- a/src/Server.hs +++ b/src/Server.hs @@ -89,7 +89,7 @@ showRawFile (ToodlesState ref _) eId = do codeLines) editTodos :: ToodlesState -> EditTodoRequest -> Handler Text -editTodos (ToodlesState ref _) req = do +editTodos s@(ToodlesState ref _) req = do storedResults <- liftIO $ readIORef ref case storedResults of (Just (TodoListResult r _)) -> do @@ -102,6 +102,7 @@ editTodos (ToodlesState ref _) req = do r editedFilteredList = filter (willEditTodo req) editedList _ <- mapM_ recordUpdates editedFilteredList + _ <- updateCache s editedFilteredList return "{}" Nothing -> error "no stored todos to edit" where @@ -130,6 +131,26 @@ editTodos (ToodlesState ref _) req = do recordUpdates :: MonadIO m => TodoEntry -> m () recordUpdates t = void $ updateTodoLinesInFile renderTodo t +data UpdateType = UpdateTypeEdit | UpdateTypeDelete deriving (Eq) + +updateCache :: MonadIO m => ToodlesState -> [TodoEntry] -> m () +updateCache (ToodlesState ref _) entries = do + storedResults <- liftIO $ readIORef ref + case storedResults of + (Just (TodoListResult currentCache _)) -> do + let idsToUpdate = map entryId entries + newCache = + TodoListResult + ((++ entries) + (filter + (\item -> entryId item `notElem` idsToUpdate) + currentCache)) + "edits applied" + _ <- + liftIO $ atomicModifyIORef' ref (const (Just newCache, Just newCache)) + return () + Nothing -> error "no stored todos to update" + renderTodo :: TodoEntry -> [Text] renderTodo t = let ext = "." <> getExtension (sourceFile t) diff --git a/toodles.cabal b/toodles.cabal index 9400f1c..5bf28e8 100644 --- a/toodles.cabal +++ b/toodles.cabal @@ -4,10 +4,10 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 95013a4e9f97f67cc56541af010980f8b66d76da59819ff6aef8c68ffdb9bc27 +-- hash: eca068224b8e938feec8b371e63c8819e81e6d2030806c1f220e08823596b7f7 name: toodles -version: 1.0.1 +version: 1.0.2 synopsis: Manage the TODO entries in your code description: Toodles scrapes your entire repository for TODO entries and organizes them so you can manage your project directly from the code. View, filter, sort, and edit your TODO\'s with an easy to use web application. When you make changes via toodles, the edits will be applied directly the TODO entries in your code. When you\'re done, commit and push your changes to share them with your team! category: Project Management