diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2025-11-22 20:24:35 +0100 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-11-22 20:24:35 +0100 |
| commit | f2ed84f1c16be93f0624ac04ccb99d24c1a0a0f3 (patch) | |
| tree | 8286d44eff86b2964503a559183df1226c6c220d | |
| parent | 8bc75bc96817e3be7ffd508e8c06b9ec6f409531 (diff) | |
Changelog: Added `/new` command to list conversations with new (unread) messages
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | main/Main.hs | 17 |
2 files changed, 20 insertions, 0 deletions
@@ -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. + `/<number>` : Select conversation, contact or peer `<number>` 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 |