diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-02-03 18:13:15 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-02-03 18:13:15 +0200 |
| commit | cac7be6c22bafc0d43fe209813c1fc1ac31a0190 (patch) | |
| tree | 9339fa91c53c8a8e5adc7e8f709aa13f053fe602 /internal/client/ui/core/state | |
| parent | ad25655d5faef4bda65b1fa96f5ebba1b4067e01 (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/state')
| -rw-r--r-- | internal/client/ui/core/state/state.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/internal/client/ui/core/state/state.go b/internal/client/ui/core/state/state.go index 08b8c55..1115c13 100644 --- a/internal/client/ui/core/state/state.go +++ b/internal/client/ui/core/state/state.go @@ -13,14 +13,14 @@ import ( "github.com/kyren223/eko/pkg/snowflake" ) -type FrequencyState struct { +type ChatState struct { IncompleteMessage string Base int MaxHeight int } type state struct { - ChatState map[snowflake.ID]FrequencyState // key is frequency id or receiver id + ChatState map[snowflake.ID]ChatState // key is frequency id or receiver id LastFrequency map[snowflake.ID]snowflake.ID // key is network id Messages map[snowflake.ID]*btree.BTreeG[data.Message] // key is frequency id or receiver id @@ -34,7 +34,7 @@ type state struct { } var State state = state{ - ChatState: map[snowflake.ID]FrequencyState{}, + ChatState: map[snowflake.ID]ChatState{}, LastFrequency: map[snowflake.ID]snowflake.ID{}, Messages: map[snowflake.ID]*btree.BTreeG[data.Message]{}, Networks: map[snowflake.ID]data.Network{}, @@ -168,6 +168,18 @@ func UpdateMessages(info *packet.MessagesInfo) { } bt.ReplaceOrInsert(message) } + + // Note: this is a naive approach + // Ideally we check each message that was added/removed + // For the frequency/receiver/sender id and only remove that + // But it can be very slow when there are thousands of messages + // TODO: when msg chunking is implemented, consider doing it per-msg + // TODO: consider checking messages count and for small counts use + // the per message approach + for id, state := range State.ChatState { + state.MaxHeight = -1 + State.ChatState[id] = state + } } func UpdateMembers(info *packet.MembersInfo) { |
