mirror of
https://github.com/diamondburned/cchat-discord.git
synced 2024-11-22 14:12:47 +00:00
Account for muted channels
This commit is contained in:
parent
2f4cb5f246
commit
360b34de2a
|
@ -40,7 +40,7 @@ func (c *Category) Name() text.Rich {
|
|||
}
|
||||
|
||||
return text.Rich{
|
||||
Content: t.Name,
|
||||
Content: "⯆ " + t.Name,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
12
channel.go
12
channel.go
|
@ -478,6 +478,14 @@ func (ch *Channel) TypingSubscribe(ti cchat.TypingIndicator) (func(), error) {
|
|||
}), nil
|
||||
}
|
||||
|
||||
// muted returns if this channel is muted. This includes the channel's category
|
||||
// and guild.
|
||||
func (ch *Channel) muted() bool {
|
||||
return (ch.guildID.Valid() && ch.session.MutedState.Guild(ch.guildID, false)) ||
|
||||
ch.session.MutedState.Channel(ch.id) ||
|
||||
ch.session.MutedState.Category(ch.id)
|
||||
}
|
||||
|
||||
func (ch *Channel) UnreadIndicate(indicator cchat.UnreadIndicator) (func(), error) {
|
||||
if rs := ch.session.ReadState.FindLast(ch.id); rs != nil {
|
||||
c, err := ch.self()
|
||||
|
@ -485,13 +493,13 @@ func (ch *Channel) UnreadIndicate(indicator cchat.UnreadIndicator) (func(), erro
|
|||
return nil, errors.Wrap(err, "Failed to get self channel")
|
||||
}
|
||||
|
||||
if c.LastMessageID > rs.LastMessageID {
|
||||
if c.LastMessageID > rs.LastMessageID && !ch.muted() {
|
||||
indicator.SetUnread(true, rs.MentionCount > 0)
|
||||
}
|
||||
}
|
||||
|
||||
return ch.session.ReadState.OnUpdate(func(ev *read.UpdateEvent) {
|
||||
if ch.id == ev.ChannelID {
|
||||
if ch.id == ev.ChannelID && !ch.muted() {
|
||||
indicator.SetUnread(ev.Unread, ev.MentionCount > 0)
|
||||
}
|
||||
}), nil
|
||||
|
|
2
go.mod
2
go.mod
|
@ -5,7 +5,7 @@ go 1.14
|
|||
require (
|
||||
github.com/diamondburned/arikawa v0.12.4
|
||||
github.com/diamondburned/cchat v0.0.45
|
||||
github.com/diamondburned/ningen v0.1.1-0.20200717013108-297a3bdf84dc
|
||||
github.com/diamondburned/ningen v0.1.1-0.20200717072304-e483f86c08e6
|
||||
github.com/dustin/go-humanize v1.0.0
|
||||
github.com/go-test/deep v1.0.6
|
||||
github.com/pkg/errors v0.9.1
|
||||
|
|
4
go.sum
4
go.sum
|
@ -77,6 +77,10 @@ github.com/diamondburned/ningen v0.1.1-0.20200716061206-b8f3ae446253 h1:Jpdv9ZnV
|
|||
github.com/diamondburned/ningen v0.1.1-0.20200716061206-b8f3ae446253/go.mod h1:Sunqp1b9Tc0+DtWKslhf83Zepgj/TELB6h8J9HZCPqQ=
|
||||
github.com/diamondburned/ningen v0.1.1-0.20200717013108-297a3bdf84dc h1:YZ84Kdlv91tdcyLfGfQ+LG9kWZN8dTKIic0KlEtGV0U=
|
||||
github.com/diamondburned/ningen v0.1.1-0.20200717013108-297a3bdf84dc/go.mod h1:Sunqp1b9Tc0+DtWKslhf83Zepgj/TELB6h8J9HZCPqQ=
|
||||
github.com/diamondburned/ningen v0.1.1-0.20200717070406-6dc482b394c0 h1:DkzeHISwAeEYIBiynYkxOz4eNuT2DfTjF93DZjyMLmc=
|
||||
github.com/diamondburned/ningen v0.1.1-0.20200717070406-6dc482b394c0/go.mod h1:Sunqp1b9Tc0+DtWKslhf83Zepgj/TELB6h8J9HZCPqQ=
|
||||
github.com/diamondburned/ningen v0.1.1-0.20200717072304-e483f86c08e6 h1:YN0cj0aOCa+tKmx0aD5qsbSYaIJnyrA0/+eygMKP+/w=
|
||||
github.com/diamondburned/ningen v0.1.1-0.20200717072304-e483f86c08e6/go.mod h1:Sunqp1b9Tc0+DtWKslhf83Zepgj/TELB6h8J9HZCPqQ=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
|
|
Loading…
Reference in a new issue