From 06ec22e7b3ff05bdfd1f038f26becea620bfa7a7 Mon Sep 17 00:00:00 2001 From: TheDaemoness Date: Thu, 15 Aug 2024 08:39:51 -0700 Subject: [PATCH 1/2] Add WLSquelch and use it to hide messages This fixes TAGMSGs not being properly hidden. --- src/Client/State.hs | 2 +- src/Client/State/Window.hs | 5 +++-- src/Client/View/Messages.hs | 8 +------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Client/State.hs b/src/Client/State.hs index d2cc4324..3deb1030 100644 --- a/src/Client/State.hs +++ b/src/Client/State.hs @@ -420,7 +420,7 @@ msgImportance msg st = NormalBody{} -> WLImportant ErrorBody{} -> WLImportant IrcBody irc - | squelchIrcMsg irc -> WLBoring + | squelchIrcMsg irc -> WLSquelch | isJust (ircIgnorable irc st) -> WLBoring | otherwise -> case irc of diff --git a/src/Client/State/Window.hs b/src/Client/State/Window.hs index b46f342f..7f52b5e1 100644 --- a/src/Client/State/Window.hs +++ b/src/Client/State/Window.hs @@ -107,7 +107,8 @@ data ActivityLevel = NoActivity | NormalActivity | HighActivity -- | Flag for the important of a message being added to a window data WindowLineImportance - = WLBoring -- ^ Don't update unread count + = WLSquelch -- ^ Hide the message entirely outside of detailed mode + | WLBoring -- ^ Don't update unread count | WLNormal -- ^ Increment unread count | WLImportant -- ^ Increment unread count and set important flag deriving (Eq, Ord, Show, Read, Enum) @@ -181,7 +182,7 @@ addToWindow !msg !win = (win', nowImportant) { _winMessages = msg :- view winMessages win , _winTotal = view winTotal win + 1 , _winMarker = (+1) <$!> view winMarker win - , _winUnread = if msgImportance == WLBoring + , _winUnread = if msgImportance <= WLBoring then view winUnread win else view winUnread win + 1 , _winMention = max oldMention msgImportance diff --git a/src/Client/View/Messages.hs b/src/Client/View/Messages.hs index 79f12d5f..299c7140 100644 --- a/src/Client/View/Messages.hs +++ b/src/Client/View/Messages.hs @@ -61,13 +61,7 @@ chatMessageImages focus w st = if hideMeta then detailedImagesWithoutMetadata st else map (view wlFullImage) - - | otherwise = windowLinesToImages st w hideMeta . filter (not . isNoisy) - - isNoisy msg = - case view wlSummary msg of - ReplySummary code -> squelchIrcMsg (Reply "" code []) - _ -> False + | otherwise = windowLinesToImages st w hideMeta . filter ((/= WLSquelch) . _wlImportance) detailedImagesWithoutMetadata :: ClientState -> [WindowLine] -> [Image'] detailedImagesWithoutMetadata st wwls = From 1e130fca248feaf5766b99f071d179853276927a Mon Sep 17 00:00:00 2001 From: TheDaemoness Date: Thu, 15 Aug 2024 08:57:03 -0700 Subject: [PATCH 2/2] Remove ReplySummary It was only being used for the previous implementation of message squelching. Numeric replies are now given NoSummary. --- src/Client/Message.hs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Client/Message.hs b/src/Client/Message.hs index 80c68263..d1acf87d 100644 --- a/src/Client/Message.hs +++ b/src/Client/Message.hs @@ -41,7 +41,7 @@ import Data.Maybe (isJust) import Data.Text (Text) import Data.Text qualified as Text import Data.Time (ZonedTime) -import Irc.Codes (ReplyCode, pattern RPL_NOWAWAY, pattern RPL_UNAWAY, pattern RPL_MONONLINE, pattern RPL_MONOFFLINE ) +import Irc.Codes ( pattern RPL_NOWAWAY, pattern RPL_UNAWAY, pattern RPL_MONONLINE, pattern RPL_MONOFFLINE ) import Irc.Identifier (Identifier, mkId) import Irc.Message (IrcMsg(..), ircMsgText, Source(srcUser)) import Irc.UserInfo (UserInfo(userNick), parseUserInfo, uiNick) @@ -71,7 +71,6 @@ data IrcSummary | QuitSummary {-# UNPACK #-} !Identifier !QuitKind | PartSummary {-# UNPACK #-} !Identifier | NickSummary {-# UNPACK #-} !Identifier {-# UNPACK #-} !Identifier - | ReplySummary {-# UNPACK #-} !ReplyCode | ChatSummary {-# UNPACK #-} !UserInfo -- userinfo to help with ignore rules | CtcpSummary {-# UNPACK #-} !Identifier | ChngSummary {-# UNPACK #-} !Identifier -- ^ Chghost command @@ -113,7 +112,6 @@ ircSummary msg = MonSummary (view uiNick $ parseUserInfo who') True Reply _ RPL_MONOFFLINE [_,who] | [who'] <- Text.split (==',') who -> MonSummary (mkId who') False - Reply _ code _ -> ReplySummary code Account who _ -> AcctSummary (userNick (srcUser who)) Chghost who _ _ -> ChngSummary (userNick (srcUser who)) Away who mb -> AwaySummary (userNick (srcUser who)) (isJust mb) @@ -139,6 +137,5 @@ summaryActor s = ChngSummary who -> Just who AwaySummary who _ -> Just who TagmSummary who -> Just who - ReplySummary {} -> Nothing MonSummary who _ -> Just who NoSummary -> Nothing