From 07de26ed7bc9ad772104008a9bb63fe455e0255d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Aug 2012 13:41:47 -0400 Subject: simple transfer queue display cleanup Don't display redundant queued downloads. The only problem with this is that it reduces the total number of queued transfers the webapp displays. --- Assistant/WebApp/DashBoard.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Assistant') diff --git a/Assistant/WebApp/DashBoard.hs b/Assistant/WebApp/DashBoard.hs index e51708d64..b04897d86 100644 --- a/Assistant/WebApp/DashBoard.hs +++ b/Assistant/WebApp/DashBoard.hs @@ -45,7 +45,7 @@ transfersDisplay warnNoScript = do queued <- liftIO $ getTransferQueue $ transferQueue webapp let ident = "transfers" autoUpdate ident NotifierTransfersR (10 :: Int) (10 :: Int) - let transfers = current ++ queued + let transfers = simplifyTransfers $ current ++ queued if null transfers then ifM (lift $ showIntro <$> getWebAppState) ( introDisplay ident @@ -56,6 +56,16 @@ transfersDisplay warnNoScript = do isrunning info = not $ transferPaused info || isNothing (startedTime info) +{- Simplifies a list of transfers, avoiding display of redundant downloads, + - that appear immediately after a download of the same key. -} +simplifyTransfers :: [(Transfer, TransferInfo)] -> [(Transfer, TransferInfo)] +simplifyTransfers [] = [] +simplifyTransfers (x:[]) = [x] +simplifyTransfers (v@(t1, _):r@((t2, _):l)) + | transferDirection t1 == Download && transferDirection t2 == Download && + transferKey t1 == transferKey t2 = simplifyTransfers (v:l) + | otherwise = v : (simplifyTransfers r) + {- Called by client to get a display of currently in process transfers. - - Returns a div, which will be inserted into the calling page. -- cgit v1.2.3