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:
parent
de2e287133
commit
909d726d1d
2 changed files with 8 additions and 6 deletions
|
@ -25,9 +25,7 @@ inFirstRun = isNothing . relDir <$> getYesod
|
|||
|
||||
newWebAppState :: IO (TMVar WebAppState)
|
||||
newWebAppState = do
|
||||
cwd <- getCurrentDirectory
|
||||
otherrepos <- filter (\p -> not (snd p `dirContains` cwd))
|
||||
<$> listRepos
|
||||
otherrepos <- listOtherRepos
|
||||
atomically $ newTMVar $ WebAppState
|
||||
{ showIntro = True
|
||||
, otherRepos = otherrepos }
|
||||
|
@ -108,9 +106,11 @@ controlMenu = do
|
|||
repolist <- lift $ otherRepos <$> getWebAppState
|
||||
$(widgetFile "controlmenu")
|
||||
|
||||
listRepos :: IO [(String, String)]
|
||||
listRepos = do
|
||||
listOtherRepos :: IO [(String, String)]
|
||||
listOtherRepos = do
|
||||
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
|
||||
return $ sort $ zip names dirs
|
||||
|
|
|
@ -148,6 +148,8 @@ getNewRepositoryR = page "Add another repository" (Just Configuration) $ do
|
|||
u <- liftIO $ initRepo True path Nothing
|
||||
runAnnex () $ setStandardGroup u ClientGroup
|
||||
liftIO $ addAutoStart path
|
||||
otherrepos <- liftIO $ listOtherRepos
|
||||
modifyWebAppState $ \s -> s { otherRepos = otherrepos }
|
||||
redirect $ SwitchToRepositoryR path
|
||||
_ -> $(widgetFile "configurators/newrepository")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue