Skip to content

Commit

Permalink
Hide blocked messages
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed Jun 13, 2022
1 parent 99ee3db commit 2e53d4d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/diamondburned/chatkit v0.0.0-20220603065622-2987cbabd0f7
github.com/diamondburned/gotk4/pkg v0.0.0-20220417091308-856167c02355
github.com/diamondburned/gotkit v0.0.0-20220607050826-b0b269db9a11
github.com/diamondburned/ningen/v3 v3.0.0-20220502092438-5560155ea46d
github.com/diamondburned/ningen/v3 v3.0.0-20220611232432-feabfbd88d5e
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ github.com/diamondburned/gotk4/pkg v0.0.0-20220417091308-856167c02355/go.mod h1:
github.com/diamondburned/gotkit v0.0.0-20220418090814-3d8ad765902d/go.mod h1:vPfJRyjYv+hBfsnWf9Ouacp1Urltx8/qy5b0TWyeZNo=
github.com/diamondburned/gotkit v0.0.0-20220607050826-b0b269db9a11 h1:bm3y9TrNUbngeOPcsDrT2O6zIUmAfxUh8i9+Ec8KE8E=
github.com/diamondburned/gotkit v0.0.0-20220607050826-b0b269db9a11/go.mod h1:vPfJRyjYv+hBfsnWf9Ouacp1Urltx8/qy5b0TWyeZNo=
github.com/diamondburned/ningen/v3 v3.0.0-20220502092438-5560155ea46d h1:R3N72rYAIDWrcIaTxzIbRJG4ldOZq1PnqGJZtXid4aw=
github.com/diamondburned/ningen/v3 v3.0.0-20220502092438-5560155ea46d/go.mod h1:WLSUx3megnWk5I6rYLE+yPHN3iPJf4Nag2B5Y7l+Vmc=
github.com/diamondburned/ningen/v3 v3.0.0-20220611232432-feabfbd88d5e h1:chZhUuRdyXfiwpsE+v2nnY+1fOL8XLnpqA2ElC8MjnA=
github.com/diamondburned/ningen/v3 v3.0.0-20220611232432-feabfbd88d5e/go.mod h1:WLSUx3megnWk5I6rYLE+yPHN3iPJf4Nag2B5Y7l+Vmc=
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
Expand Down
2 changes: 1 addition & 1 deletion internal/gtkcord/message/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ const defaultMentionColor = "#6F78DB"

func mentionTag(r *mdrender.Renderer, color string) *gtk.TextTag {
tag := textutil.TextTag{"background": color + "76"}
return tag.FromTable(r.State.TagTable(), "")
return tag.FromTable(r.State.TagTable(), tag.Hash())
}

func renderMention(r *mdrender.Renderer, n ast.Node) ast.WalkStatus {
Expand Down
7 changes: 7 additions & 0 deletions internal/gtkcord/message/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ func NewView(ctx context.Context, chID discord.ChannelID) *View {
}
}

// See if this message belongs to a blocked user. If it is, then
// don't add it.
if state.RelationshipState.IsBlocked(ev.Author.ID) {
log.Println("ignoring message from blocked user", ev.Author.Tag())
return
}

msg := v.upsertMessage(ev.ID, newMessageInfo(&ev.Message))
msg.Update(ev)

Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/diamondburned/adaptive"
"github.com/diamondburned/gotkit/app"
"github.com/diamondburned/gotkit/components/logui"
"github.com/diamondburned/gotkit/components/prefui"
"github.com/diamondburned/gotkit/gtkutil/cssutil"
"github.com/diamondburned/gtkcord4/internal/gtkcord"
Expand All @@ -30,6 +31,7 @@ func main() {
"app.open-channel": m.openChannel,
"app.preferences": func() { prefui.ShowDialog(app.Context()) },
"app.about": func() { /* TODO */ },
"app.logs": func() { logui.ShowDefaultViewer(app.Context()) },
"app.quit": func() { app.Quit() },
})
app.ConnectActivate(func() { m.activate(app.Context()) })
Expand Down

0 comments on commit 2e53d4d

Please sign in to comment.