From 52490d15b6f6d0b3d30c6c386a08682cd1a483ff Mon Sep 17 00:00:00 2001 From: ayntgl <90600421+ayntgl@users.noreply.github.com> Date: Fri, 28 Jan 2022 10:52:44 +0400 Subject: [PATCH] fix(ui): check if selected channel's ID is same as received message's channel's ID (#120) --- ui/app.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ui/app.go b/ui/app.go index c62e54e..95f678d 100644 --- a/ui/app.go +++ b/ui/app.go @@ -89,14 +89,12 @@ func (app *App) onGuildCreate(_ *discordgo.Session, g *discordgo.GuildCreate) { } func (app *App) onSessionMessageCreate(_ *discordgo.Session, m *discordgo.MessageCreate) { - if app.SelectedChannel == nil { - return - } + if app.SelectedChannel != nil && app.SelectedChannel.ID == m.ChannelID { + app.SelectedChannel.Messages = append(app.SelectedChannel.Messages, m.Message) + app.MessagesTextView.Write(buildMessage(app, m.Message)) - app.SelectedChannel.Messages = append(app.SelectedChannel.Messages, m.Message) - app.MessagesTextView.Write(buildMessage(app, m.Message)) - - if len(app.MessagesTextView.GetHighlights()) == 0 { - app.MessagesTextView.ScrollToEnd() + if len(app.MessagesTextView.GetHighlights()) == 0 { + app.MessagesTextView.ScrollToEnd() + } } }