From e5d8ca9c124c4f8805bba9212845f0e21de5d9fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 23 Jun 2026 21:43:56 +0200 Subject: Format chatroom messages with Conversation module --- src/Erebos/Conversation.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/Erebos/Conversation.hs') diff --git a/src/Erebos/Conversation.hs b/src/Erebos/Conversation.hs index 0e6690e..78774bd 100644 --- a/src/Erebos/Conversation.hs +++ b/src/Erebos/Conversation.hs @@ -74,11 +74,15 @@ formatMessage :: TimeZone -> Message -> String formatMessage tzone = T.unpack . renderPlainText . formatMessageFT tzone formatMessageFT :: TimeZone -> Message -> FormattedText -formatMessageFT tzone msg = mconcat - [ PlainText $ T.pack $ formatTime defaultTimeLocale "[%H:%M] " $ utcToLocalTime tzone $ zonedTimeToUTC $ messageTime msg - , maybe "" PlainText $ idName $ messageFrom msg - , maybe "" ((": " <>) . PlainText) $ messageText msg +formatMessageFT tzone msg = mconcat $ concat + [ [ PlainText $ T.pack $ formatTime defaultTimeLocale "[%H:%M] " $ utcToLocalTime tzone $ zonedTimeToUTC $ messageTime msg ] + , [ maybe "" PlainText $ idName $ messageFrom msg ] + , map formatExtra $ withMessage convMessageExtra msg + , [ maybe "" ((": " <>) . PlainText) $ messageText msg ] ] + where + formatExtra UserJoined = " " <> withStyle (setForegroundColor BrightMagenta noStyle) (plainText "joined") + formatExtra UserLeft = " " <> withStyle (setForegroundColor Magenta noStyle) (plainText "left") data Conversation -- cgit v1.2.3