diff options
Diffstat (limited to 'internal/client/ui/core')
| -rw-r--r-- | internal/client/ui/core/core.go | 3 | ||||
| -rw-r--r-- | internal/client/ui/core/state/state.go | 15 |
2 files changed, 18 insertions, 0 deletions
diff --git a/internal/client/ui/core/core.go b/internal/client/ui/core/core.go index b46a22b..fce8414 100644 --- a/internal/client/ui/core/core.go +++ b/internal/client/ui/core/core.go @@ -332,6 +332,9 @@ func (m *Model) updateConnected(message tea.Msg) tea.Cmd { case *packet.BlockInfo: state.UpdateBlockedUsers(msg) + case *packet.UsersInfo: + state.UpdateUsersInfo(msg) + case *packet.NotificationsInfo: signals := state.UpdateNotifications(msg) if m.networkList.Index() == networklist.SignalsIndex { diff --git a/internal/client/ui/core/state/state.go b/internal/client/ui/core/state/state.go index da894ed..75fd8a7 100644 --- a/internal/client/ui/core/state/state.go +++ b/internal/client/ui/core/state/state.go @@ -144,6 +144,7 @@ func UpdateMessages(info *packet.MessagesInfo) { } } + unknownUsers := []snowflake.ID{} for _, message := range info.Messages { msgSource := message.FrequencyID if msgSource == nil { @@ -160,8 +161,16 @@ func UpdateMessages(info *packet.MessagesInfo) { State.Messages[*msgSource] = bt } bt.ReplaceOrInsert(message) + + if _, ok := State.Users[message.SenderID]; !ok { + unknownUsers = append(unknownUsers, message.SenderID) + } } + gateway.SendAsync(&packet.GetUsers{ + Users: unknownUsers, + }) + // 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 @@ -360,3 +369,9 @@ func UpdateBlockedUsers(info *packet.BlockInfo) { State.BlockingUsers[blocking] = struct{}{} } } + +func UpdateUsersInfo(info *packet.UsersInfo) { + for _, user := range info.Users { + State.Users[user.ID] = user + } +} |
