Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WLSquelch and use it to hide messages #126

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/Client/Message.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/Client/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/Client/State/Window.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions src/Client/View/Messages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Loading