no longer need webapp state storage! excellent

This commit is contained in:
Joey Hess 2013-03-15 01:01:25 -04:00
parent 8ca2aa1cba
commit 9cf4701a8f
3 changed files with 0 additions and 21 deletions

View file

@ -57,7 +57,6 @@ webAppThread assistantdata urlrenderer noannex postfirstrun onstartup = thread $
<*> (pack <$> genRandomToken)
<*> getreldir
<*> pure $(embed "static")
<*> newWebAppState
<*> pure postfirstrun
<*> pure noannex
setUrlRenderer urlrenderer $ yesodRender webapp (pack "")

View file

@ -17,25 +17,11 @@ import Utility.Yesod
import Yesod
import Data.Text (Text)
import Control.Concurrent.STM
import Control.Concurrent
inFirstRun :: Handler Bool
inFirstRun = isNothing . relDir <$> getYesod
newWebAppState :: IO (TMVar WebAppState)
newWebAppState = atomically $ newTMVar $ WebAppState { showIntro = True }
getWebAppState :: forall sub. GHandler sub WebApp WebAppState
getWebAppState = liftIO . atomically . readTMVar =<< webAppState <$> getYesod
modifyWebAppState :: forall sub. (WebAppState -> WebAppState) -> GHandler sub WebApp ()
modifyWebAppState a = go =<< webAppState <$> getYesod
where
go s = liftIO $ atomically $ do
v <- takeTMVar s
putTMVar s $ a v
{- Runs an Annex action from the webapp.
-
- When the webapp is run outside a git-annex repository, the fallback

View file

@ -26,7 +26,6 @@ import Yesod
import Yesod.Static
import Text.Hamlet
import Data.Text (Text, pack, unpack)
import Control.Concurrent.STM
publicFiles "static"
@ -37,7 +36,6 @@ data WebApp = WebApp
, secretToken :: Text
, relDir :: Maybe FilePath
, getStatic :: Static
, webAppState :: TMVar WebAppState
, postFirstRun :: Maybe (IO String)
, noAnnex :: Bool
}
@ -75,10 +73,6 @@ instance RenderMessage WebApp FormMessage where
type Form x = Html -> MForm WebApp WebApp (FormResult x, Widget)
data WebAppState = WebAppState
{ showIntro :: Bool -- should the into message be displayed?
}
data RepoSelector = RepoSelector
{ onlyCloud :: Bool
, onlyConfigured :: Bool