summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2024-12-24 18:35:56 +0200
committerKyren223 <Kyren223@proton.me>2024-12-24 18:35:56 +0200
commitf6eb3d665e75d59afdae62ccfac7e1719d54e1c4 (patch)
tree53749a6ed6232e1c38e3f537adaf993e0e29ec7e /internal
parentd3d027f19eb8341eea4a321699ce1050de7cbfab (diff)
Scrolling beyond the first message is now impossible even when the
screen is not filled with messages
Diffstat (limited to 'internal')
-rw-r--r--internal/client/ui/core/chat/chat.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go
index 286272e..c94db31 100644
--- a/internal/client/ui/core/chat/chat.go
+++ b/internal/client/ui/core/chat/chat.go
@@ -416,10 +416,12 @@ func (m *Model) renderMessages(screenHeight int) string {
renderedGroup := m.renderMessageGroup(group, &remainingHeight, height)
renderedGroups = append(renderedGroups, renderedGroup)
- if remainingHeight > 0 && m.offset != SnapToBottom {
+ if remainingHeight > 0 {
m.maxMessagesHeight = height - remainingHeight
- m.offset = min(m.offset, m.maxMessagesHeight+1)
- m.index = min(m.index, m.offset-2)
+ if m.offset != SnapToBottom {
+ m.offset = min(m.offset, m.maxMessagesHeight+1)
+ m.index = min(m.index, m.offset-2)
+ }
}
}
@@ -608,6 +610,11 @@ func (m *Model) Scroll(amount int) {
if amount > 0 {
// Scrolling up
+ if m.offset == SnapToBottom && m.maxMessagesHeight != -1 {
+ m.index = min(m.index, m.maxMessagesHeight-1)
+ return
+ }
+
maxHeight := m.offset
if m.offset == SnapToBottom {
maxHeight = m.messagesHeight