From f2ed84f1c16be93f0624ac04ccb99d24c1a0a0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 22 Nov 2025 20:24:35 +0100 Subject: Command to list conversations with new messages Changelog: Added `/new` command to list conversations with new (unread) messages --- README.md | 3 +++ main/Main.hs | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index f7ad6ae..28b203d 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,9 @@ Test chatroom [19:03] Some Name: Hi `/conversations` : List started conversations with contacts or other peers. +`/new` +: List conversations with new (unread) messages. + `/` : Select conversation, contact or peer `` based on the last `/conversations`, `/contacts` or `/peers` output list. diff --git a/main/Main.hs b/main/Main.hs index d7d42aa..a876d7b 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -621,6 +621,7 @@ commands = , ( "contact-accept", cmdContactAccept ) , ( "contact-reject", cmdContactReject ) , ( "conversations", cmdConversations ) + , ( "new", cmdNew ) , ( "details", cmdDetails ) , ( "discovery", cmdDiscovery ) , ( "join", cmdJoin ) @@ -959,6 +960,22 @@ cmdConversations = do forM_ (zip [1..] conversations) $ \(i :: Int, conv) -> do cmdPutStrLn $ "[" ++ show i ++ "] " ++ T.unpack (conversationName conv) +cmdNew :: Command +cmdNew = do + conversations <- mapMaybe checkNew <$> lookupConversations + set <- asks ciSetContextOptions + set WatchConversations $ map (SelectedConversation . fst) conversations + tzone <- liftIO $ getCurrentTimeZone + forM_ (zip [1..] conversations) $ \(i :: Int, ( conv, msg )) -> do + cmdPutStrLn $ "[" ++ show i ++ "] " ++ T.unpack (conversationName conv) ++ " " ++ formatMessage tzone msg + where + checkNew conv + | (msg : _) <- conversationHistory conv + , messageUnread msg + = Just ( conv, msg ) + checkNew _ = Nothing + + cmdDetails :: Command cmdDetails = do getSelectedOrManualContext >>= \case -- cgit v1.2.3