diff --git a/discord.go b/discord.go index cc50030..e9ee438 100644 --- a/discord.go +++ b/discord.go @@ -80,6 +80,8 @@ func onSessionMessageCreate(_ *discordgo.Session, m *discordgo.MessageCreate) { } else { selectedChannel.Messages = append(selectedChannel.Messages, m.Message) messagesView.Write(buildMessage(m.Message)) + // Scroll to the end of the text after the message has been written to the TextView. + messagesView.ScrollToEnd() } } diff --git a/ui.go b/ui.go index b61796d..87f90be 100644 --- a/ui.go +++ b/ui.go @@ -100,6 +100,8 @@ func onChannelsTreeSelected(n *tview.TreeNode) { selectedChannel.Messages = append(selectedChannel.Messages, ms[i]) messagesView.Write(buildMessage(ms[i])) } + // Scroll to the end of the text after the messages have been written to the TextView. + messagesView.ScrollToEnd() if len(ms) != 0 && isUnread(c) { session.ChannelMessageAck(c.ID, c.LastMessageID, "") @@ -114,7 +116,6 @@ func newMessagesView() *tview.TextView { SetRegions(true). SetDynamicColors(true). SetWordWrap(true). - ScrollToEnd(). SetChangedFunc(func() { app.Draw() }).