From 059f803a71d1f04ca25a114a31a38866550f61f5 Mon Sep 17 00:00:00 2001 From: Jens Nolte <jens@nightmarestudio.de> Date: Mon, 2 Mar 2020 16:36:51 +0100 Subject: [PATCH] Always set block names --- src/QBar/Core.hs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/QBar/Core.hs b/src/QBar/Core.hs index aa49794..cdb41bc 100644 --- a/src/QBar/Core.hs +++ b/src/QBar/Core.hs @@ -250,7 +250,7 @@ newCache'' = do -- |Creates a cache from a push block. cachePushBlock :: PushBlock -> BlockCache -cachePushBlock pushBlock = newCache $ () <$ (pushBlock >-> updateBarP >-> fixBlockName >-> PP.map (\a -> [a])) +cachePushBlock pushBlock = newCache $ () <$ (pushBlock >-> updateBarP >-> addBlockName >-> PP.map (\a -> [a])) where updateBarP :: Pipe BlockUpdate BlockState BarIO r updateBarP = forever $ do @@ -259,15 +259,12 @@ cachePushBlock pushBlock = newCache $ () <$ (pushBlock >-> updateBarP >-> fixBlo updateBar reason -- |Sets 'blockName' to a random (but static) identifier if an event handler is set but the 'blockName' is not set. - fixBlockName :: Pipe BlockState BlockState BarIO r - fixBlockName = do + addBlockName :: Pipe BlockState BlockState BarIO r + addBlockName = do defaultBlockName <- randomIdentifier forever $ do state <- await - yield $ if hasEventHandler state - then (_Just . _1 . blockName) %~ (Just . fromMaybe defaultBlockName) $ state - else state - + yield $ (_Just . _1 . blockName) %~ (Just . fromMaybe defaultBlockName) $ state modify :: (BlockOutput -> BlockOutput) -> Pipe BlockUpdate BlockUpdate BarIO r @@ -295,7 +292,6 @@ autoPadding = autoPadding' 0 0 padShortText :: Int64 -> BlockOutput -> BlockOutput padShortText len = over (shortText._Just) $ \s -> padString (len - printedLength s) <> s - addBlock :: IsCachable a => a -> BarIO () addBlock block = do newBlockChan' <- newBlockChan <$> askBar -- GitLab