diff options
| -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 |