From 887fb6143ba86b799a6730e36de3732e1330db0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 6 Jul 2024 11:35:28 +0200 Subject: Chatrooms in conversation interface --- main/Main.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'main/Main.hs') diff --git a/main/Main.hs b/main/Main.hs index 091f076..3c1494d 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -506,9 +506,11 @@ cmdSend :: Command cmdSend = void $ do text <- asks ciLine conv <- getSelectedConversation - msg <- sendMessage conv $ T.pack text - tzone <- liftIO $ getCurrentTimeZone - liftIO $ putStrLn $ formatMessage tzone msg + sendMessage conv (T.pack text) >>= \case + Just msg -> do + tzone <- liftIO $ getCurrentTimeZone + liftIO $ putStrLn $ formatMessage tzone msg + Nothing -> return () cmdHistory :: Command cmdHistory = void $ do @@ -535,13 +537,11 @@ cmdAttachReject = attachReject =<< getSelectedPeer cmdChatrooms :: Command cmdChatrooms = do - chatrooms <- listChatrooms - forM_ chatrooms $ \case - rstate | Just room <- roomStateRoom rstate -> do - liftIO $ T.putStrLn $ T.concat - [ fromMaybe (T.pack "") $ roomName room - ] - _ -> return () + conversations <- return . catMaybes =<< mapM chatroomConversation =<< listChatrooms + set <- asks ciSetContextOptions + set $ map SelectedConversation conversations + forM_ (zip [1..] conversations) $ \(i :: Int, conv) -> do + liftIO $ putStrLn $ "[" ++ show i ++ "] " ++ T.unpack (conversationName conv) cmdChatroomCreatePublic :: Command cmdChatroomCreatePublic = do -- cgit v1.2.3