update list of other repos when adding one

This way, once it switches to the new repo, the user can switch back to the
old one, and its menu will allow switching to the new again.

However, if there are multiple repos, the others don't yet learn about the
new repo.
This commit is contained in:
Joey Hess 2013-01-03 15:34:50 -04:00
parent de2e287133
commit 909d726d1d
2 changed files with 8 additions and 6 deletions

View file

@ -25,9 +25,7 @@ inFirstRun = isNothing . relDir <$> getYesod
newWebAppState :: IO (TMVar WebAppState) newWebAppState :: IO (TMVar WebAppState)
newWebAppState = do newWebAppState = do
cwd <- getCurrentDirectory otherrepos <- listOtherRepos
otherrepos <- filter (\p -> not (snd p `dirContains` cwd))
<$> listRepos
atomically $ newTMVar $ WebAppState atomically $ newTMVar $ WebAppState
{ showIntro = True { showIntro = True
, otherRepos = otherrepos } , otherRepos = otherrepos }
@ -108,9 +106,11 @@ controlMenu = do
repolist <- lift $ otherRepos <$> getWebAppState repolist <- lift $ otherRepos <$> getWebAppState
$(widgetFile "controlmenu") $(widgetFile "controlmenu")
listRepos :: IO [(String, String)] listOtherRepos :: IO [(String, String)]
listRepos = do listOtherRepos = do
f <- autoStartFile f <- autoStartFile
dirs <- nub <$> ifM (doesFileExist f) ( lines <$> readFile f, return []) cwd <- getCurrentDirectory
dirs <- filter (\d -> not $ d `dirContains` cwd) . nub
<$> ifM (doesFileExist f) ( lines <$> readFile f, return [])
names <- mapM relHome dirs names <- mapM relHome dirs
return $ sort $ zip names dirs return $ sort $ zip names dirs

View file

@ -148,6 +148,8 @@ getNewRepositoryR = page "Add another repository" (Just Configuration) $ do
u <- liftIO $ initRepo True path Nothing u <- liftIO $ initRepo True path Nothing
runAnnex () $ setStandardGroup u ClientGroup runAnnex () $ setStandardGroup u ClientGroup
liftIO $ addAutoStart path liftIO $ addAutoStart path
otherrepos <- liftIO $ listOtherRepos
modifyWebAppState $ \s -> s { otherRepos = otherrepos }
redirect $ SwitchToRepositoryR path redirect $ SwitchToRepositoryR path
_ -> $(widgetFile "configurators/newrepository") _ -> $(widgetFile "configurators/newrepository")