diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-02-03 17:38:19 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-02-03 17:38:19 +0200 |
| commit | ad25655d5faef4bda65b1fa96f5ebba1b4067e01 (patch) | |
| tree | 27423c979b2e0e4c06d885bca4a3a773d8d4a4fc /internal/client/ui/core/chat/chat.go | |
| parent | c0013eba3791c80c2d9d51c1fa5ac228242bd5c4 (diff) | |
Fixed first message of a user triggering the "new" line if there were no
new messages in the frequency/receiver
Diffstat (limited to 'internal/client/ui/core/chat/chat.go')
| -rw-r--r-- | internal/client/ui/core/chat/chat.go | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go index 4731005..528c02b 100644 --- a/internal/client/ui/core/chat/chat.go +++ b/internal/client/ui/core/chat/chat.go @@ -210,7 +210,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { frequency := frequencies[m.frequencyIndex] member := state.State.Members[*networkId][*state.UserID] - lastMsg := state.GetLastReadMessage(frequency.ID) + lastMsg := state.GetLastMessage(frequency.ID) if m.base != SnapToBottom { m.keepLastRead = false } else if lastMsg != nil { @@ -257,7 +257,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { } else if m.receiverIndex != -1 { receiverId := state.Data.Peers[m.receiverIndex] - lastMsg := state.GetLastReadMessage(receiverId) + lastMsg := state.GetLastMessage(receiverId) if m.base == SnapToBottom && lastMsg != nil { lastReadMsg := state.Data.LastReadMessage[receiverId] @@ -743,8 +743,8 @@ func (m *Model) RestoreAfterSwitch() tea.Cmd { log.Println("Restoring frequency:", frequency.ID) m.lastReadMsg = state.Data.LastReadMessage[frequency.ID] - if m.lastReadMsg != nil { - log.Println("LAST READ MSG", m.lastReadMsg) + lastMsg := state.GetLastMessage(frequency.ID) + if m.lastReadMsg != nil && lastMsg != nil && *m.lastReadMsg != *lastMsg { m.keepLastRead = true } @@ -766,7 +766,8 @@ func (m *Model) RestoreAfterSwitch() tea.Cmd { log.Println("Restoring signal:", receiverId) m.lastReadMsg = state.Data.LastReadMessage[receiverId] - if m.lastReadMsg != nil { + lastMsg := state.GetLastMessage(receiverId) + if m.lastReadMsg != nil && lastMsg != nil && *m.lastReadMsg != *lastMsg { m.keepLastRead = true } @@ -888,11 +889,6 @@ func (m *Model) renderMessages(screenHeight int) string { lastReadId := state.Data.LastReadMessage[*id] if m.keepLastRead { - // assert.NotNil(m.lastReadMsg, "TODO: REMOVE THIS", "lastReadId", lastReadId, "m.lastReadMsg", m.lastReadMsg) - // assert.Assert(*m.lastReadMsg != *lastReadId, "TODO: REMOVE THIS", "lastReadId", lastReadId, "m.lastReadMsg", m.lastReadMsg) - if m.lastReadMsg != nil && lastReadId != nil && *m.lastReadMsg == *lastReadId { - log.Println("TODO: REMOVE THIS", "lastReadId", lastReadId, "m.lastReadMsg", m.lastReadMsg) - } lastReadId = m.lastReadMsg } |
