summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-07-16 18:39:54 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2024-07-16 20:29:19 +0200
commit35066bdbd2475b632dfb3d824a297cbbaa7b1aa3 (patch)
tree86183ea01684b6d7651c205f067d797f61674d25 /main
parent79833be3be44766a967f4f1427d9de64b14fee5b (diff)
Start watching chatrooms on startup if there are any subscriptions
Diffstat (limited to 'main')
-rw-r--r--main/Main.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/main/Main.hs b/main/Main.hs
index dfa3e1b..d5b06ea 100644
--- a/main/Main.hs
+++ b/main/Main.hs
@@ -295,9 +295,11 @@ interactiveLoop st opts = runInputT inputSettings $ do
contextOptions <- liftIO $ newMVar []
chatroomSetVar <- liftIO $ newEmptyMVar
- watched <- case optChatroomAutoSubscribe opts of
- auto@(Just _) -> fmap Just $ liftIO $ watchChatroomsForCli extPrintLn erebosHead chatroomSetVar contextOptions auto
- Nothing -> return Nothing
+ let autoSubscribe = optChatroomAutoSubscribe opts
+ chatroomList = fromSetBy (comparing roomStateData) . lookupSharedValue . lsShared . headObject $ erebosHead
+ watched <- if isJust autoSubscribe || any roomStateSubscribe chatroomList
+ then fmap Just $ liftIO $ watchChatroomsForCli extPrintLn erebosHead chatroomSetVar contextOptions autoSubscribe
+ else return Nothing
server <- liftIO $ do
startServer (optServer opts) erebosHead extPrintLn $