diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2024-07-06 11:35:28 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2024-07-06 13:04:54 +0200 |
commit | 887fb6143ba86b799a6730e36de3732e1330db0b (patch) | |
tree | 5f13cf2d0382ee42f17d940e3d0e03257f6383fc /main | |
parent | c7f64b37e6442504fe5c41dbce6e7078cb434f31 (diff) |
Chatrooms in conversation interface
Diffstat (limited to 'main')
-rw-r--r-- | main/Main.hs | 20 | ||||
-rw-r--r-- | main/Test.hs | 2 |
2 files changed, 11 insertions, 11 deletions
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 "<unnamed>") $ 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 diff --git a/main/Test.hs b/main/Test.hs index 711f9fa..6b6d1d4 100644 --- a/main/Test.hs +++ b/main/Test.hs @@ -758,4 +758,4 @@ cmdChatroomMessageSend :: Command cmdChatroomMessageSend = do [cid, msg] <- asks tiParams to <- getChatroomStateData cid - void $ chatroomMessageByStateData to msg + void $ sendChatroomMessageByStateData to msg |