fix: scroll to end of text on channel select (#85)

This commit is contained in:
ayntgl 2021-10-28 17:10:48 +04:00 • committed by GitHub
parent 5c6d596ac3
commit cfee278be8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -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()
}
}

3
ui.go
View file

@ -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()
}).