@@ -30,8 +30,7 @@ import Try.Editor (MarkerType(..), toStringMarkerType)
3030import Try.Editor as Editor
3131import Try.Gist (getGistById , tryLoadFileFromGist )
3232import Try.GitHub (getRawGitHubFile )
33- import Try.QueryString (getQueryStringMaybe )
34- import Try.Session (createSessionIdIfNecessary , storeSession , tryRetrieveSession )
33+ import Try.QueryString (compressToEncodedURIComponent , decompressFromEncodedURIComponent , getQueryStringMaybe , setQueryString )
3534import Try.SharedConfig as SharedConfig
3635import Type.Proxy (Proxy (..))
3736import Web.HTML (window )
@@ -109,8 +108,7 @@ component = H.mkComponent
109108 handleAction :: Action -> H.HalogenM State Action Slots o Aff Unit
110109 handleAction = case _ of
111110 Initialize -> do
112- sessionId <- H .liftEffect $ createSessionIdIfNecessary
113- { code, sourceFile } <- H .liftAff $ withSession sessionId
111+ { code, sourceFile } <- H .liftAff withSession
114112
115113 -- Load parameters
116114 mbViewModeParam <- H .liftEffect $ getQueryStringMaybe " view"
@@ -141,12 +139,7 @@ component = H.mkComponent
141139 handleAction $ Compile Nothing
142140
143141 Cache text -> H .liftEffect do
144- sessionId <- getQueryStringMaybe " session"
145- case sessionId of
146- Just sessionId_ -> do
147- storeSession sessionId_ { code: text }
148- Nothing ->
149- error " No session ID"
142+ setQueryString " purs" $ compressToEncodedURIComponent text
150143
151144 Compile mbCode -> do
152145 H .modify_ _ { compiled = Nothing }
@@ -505,13 +498,13 @@ toAnnotation markerType { position, message } =
505498 , text: message
506499 }
507500
508- withSession :: String -> Aff { sourceFile :: Maybe SourceFile , code :: String }
509- withSession sessionId = do
510- state <- H .liftEffect $ tryRetrieveSession sessionId
511- githubId <- H .liftEffect $ getQueryStringMaybe " github"
501+ withSession :: Aff { sourceFile :: Maybe SourceFile , code :: String }
502+ withSession = do
503+ state <- H .liftEffect $ getQueryStringMaybe " purs "
504+ githubId <- H .liftEffect $ getQueryStringMaybe " github"
512505 gistId <- H .liftEffect $ getQueryStringMaybe " gist"
513- code <- case state of
514- Just { code } -> pure code
506+ code <- case state >>= decompressFromEncodedURIComponent of
507+ Just code -> pure code
515508 Nothing -> do
516509 let
517510 action = oneOf
0 commit comments