From 35066bdbd2475b632dfb3d824a297cbbaa7b1aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 16 Jul 2024 18:39:54 +0200 Subject: Start watching chatrooms on startup if there are any subscriptions --- main/Main.hs | 8 +++++--- 1 file 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 $ -- cgit v1.2.3