fix(ui): draw only selected channel's messages if notifications are disabled (#258)

Co-authored-by: ayn2op <ayn2op@gmail.com>
This commit is contained in:
ayntgl 2022-12-03 13:12:17 +05:30 • committed by GitHub
parent 50174ef0d2
commit c6d0525884
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -191,20 +191,22 @@ func (c *Application) onGuildDelete(g *gateway.GuildDeleteEvent) {
}
func (c *Application) onMessageCreate(m *gateway.MessageCreateEvent) {
if (c.view.ChannelsView.selected == nil || c.view.ChannelsView.selected.ID != m.ChannelID) && c.config.Notifications {
g, err := c.state.Cabinet.Guild(m.GuildID)
if err != nil {
log.Println(err)
return
}
if c.view.ChannelsView.selected == nil {
if c.config.Notifications {
g, err := c.state.Cabinet.Guild(m.GuildID)
if err != nil {
log.Println(err)
return
}
c, err := c.state.Cabinet.Channel(m.ChannelID)
if err != nil {
log.Println(err)
return
}
c, err := c.state.Cabinet.Channel(m.ChannelID)
if err != nil {
log.Println(err)
return
}
go beeep.Notify(fmt.Sprintf("%s %s", g.Name, c.Name), m.Content, "")
go beeep.Notify(fmt.Sprintf("%s %s", g.Name, c.Name), m.Content, "")
}
} else {
_, err := c.view.MessagesView.Write(buildMessage(c, m.Message))
if err != nil {