Skip to content

Commit

Permalink
Automatically assign to lastSuccessfulCompilationResult if compilatio…
Browse files Browse the repository at this point in the history
…nResult is updated
  • Loading branch information
sjoerdvisscher committed Oct 12, 2021
1 parent c1cdefe commit 968ca2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 10 additions & 2 deletions plutus-playground-client/src/MainFrame/Lenses.purs
Expand Up @@ -38,7 +38,7 @@ import Control.Monad.State.Class (class MonadState)
import Cursor (Cursor)
import Data.Either (Either)
import Data.Json.JsonTuple (JsonTuple)
import Data.Lens (Lens', Traversal', _Right)
import Data.Lens (Lens', Traversal', _Right, lens, is)
import Data.Lens.Extra (peruse)
import Data.Lens.Iso.Newtype (_Newtype)
import Data.Lens.Record (prop)
Expand Down Expand Up @@ -91,7 +91,15 @@ _lastEvaluatedSimulation :: Lens' State (Maybe Simulation)
_lastEvaluatedSimulation = _Newtype <<< prop (SProxy :: SProxy "lastEvaluatedSimulation")

_compilationResult :: Lens' State (WebData (Either InterpreterError (InterpreterResult CompilationResult)))
_compilationResult = _Newtype <<< prop (SProxy :: SProxy "compilationResult")
_compilationResult = _Newtype <<< lens g s
where
g r = r.compilationResult

s r c =
if is (_Success <<< _Right) c then
r { compilationResult = c, lastSuccessfulCompilationResult = c }
else
r { compilationResult = c }

_successfulCompilationResult :: Traversal' State CompilationResult
_successfulCompilationResult = _compilationResult <<< _Success <<< _Right <<< _InterpreterResult <<< _result
Expand Down
2 changes: 0 additions & 2 deletions plutus-playground-client/src/MainFrame/State.purs
Expand Up @@ -257,7 +257,6 @@ handleAction (LoadScript key) = do
assign (_editorState <<< _lastCompiledCode) (Just contractDemoEditorContents)
assign (_editorState <<< _currentCodeIsCompiled) true
assign _compilationResult (Success <<< Right $ contractDemoContext)
assign _lastSuccessfulCompilationResult (Success <<< Right $ contractDemoContext)
assign _evaluationResult NotAsked
assign _createGistResult NotAsked

Expand Down Expand Up @@ -345,7 +344,6 @@ handleAction CompileProgram = do
when (isSuccess newCompilationResult) do
assign (_editorState <<< _lastCompiledCode) (Just contents)
assign (_editorState <<< _currentCodeIsCompiled) true
assign _lastSuccessfulCompilationResult newCompilationResult
-- Update the error display.
editorSetAnnotations
$ case newCompilationResult of
Expand Down

0 comments on commit 968ca2f

Please sign in to comment.