summaryrefslogtreecommitdiff
path: root/internal/client/ui/core/chat/chat.go
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2025-02-03 18:13:15 +0200
committerKyren223 <Kyren223@proton.me>2025-02-03 18:13:15 +0200
commitcac7be6c22bafc0d43fe209813c1fc1ac31a0190 (patch)
tree9339fa91c53c8a8e5adc7e8f709aa13f053fe602 /internal/client/ui/core/chat/chat.go
parentad25655d5faef4bda65b1fa96f5ebba1b4067e01 (diff)
Fixed a bug where users weren't able to scroll higher if they already
got to the top message but then more messages have been added
Diffstat (limited to 'internal/client/ui/core/chat/chat.go')
-rw-r--r--internal/client/ui/core/chat/chat.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go
index 528c02b..9451de7 100644
--- a/internal/client/ui/core/chat/chat.go
+++ b/internal/client/ui/core/chat/chat.go
@@ -210,6 +210,10 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
frequency := frequencies[m.frequencyIndex]
member := state.State.Members[*networkId][*state.UserID]
+ if s, ok := state.State.ChatState[frequency.ID]; ok {
+ m.maxMessagesHeight = s.MaxHeight
+ }
+
lastMsg := state.GetLastMessage(frequency.ID)
if m.base != SnapToBottom {
m.keepLastRead = false
@@ -257,6 +261,10 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
} else if m.receiverIndex != -1 {
receiverId := state.Data.Peers[m.receiverIndex]
+ if s, ok := state.State.ChatState[receiverId]; ok {
+ m.maxMessagesHeight = s.MaxHeight
+ }
+
lastMsg := state.GetLastMessage(receiverId)
if m.base == SnapToBottom && lastMsg != nil {
lastReadMsg := state.Data.LastReadMessage[receiverId]
@@ -713,7 +721,7 @@ func (m *Model) ResetBeforeSwitch() {
}
frequencyId := frequencies[m.frequencyIndex].ID
log.Println("Saving frequency", frequencyId)
- state.State.ChatState[frequencyId] = state.FrequencyState{
+ state.State.ChatState[frequencyId] = state.ChatState{
IncompleteMessage: m.vi.String(),
Base: m.base,
MaxHeight: m.maxMessagesHeight,
@@ -724,7 +732,7 @@ func (m *Model) ResetBeforeSwitch() {
} else if m.receiverIndex != -1 {
receiverId := state.Data.Peers[m.receiverIndex]
log.Println("Saving signal:", receiverId)
- state.State.ChatState[receiverId] = state.FrequencyState{
+ state.State.ChatState[receiverId] = state.ChatState{
IncompleteMessage: m.vi.String(),
Base: m.base,
MaxHeight: m.maxMessagesHeight,
@@ -951,6 +959,14 @@ func (m *Model) renderMessages(screenHeight int) string {
if ok && last == first.ID {
m.maxMessagesHeight = height - remainingHeight
m.SetIndex(m.index)
+ if s, ok := state.State.ChatState[*id]; ok {
+ s.MaxHeight = m.maxMessagesHeight
+ state.State.ChatState[*id] = s
+ } else {
+ state.State.ChatState[*id] = state.ChatState{
+ MaxHeight: m.maxMessagesHeight,
+ }
+ }
}
var builder strings.Builder