diff options
Diffstat (limited to 'internal/client/ui/core/core.go')
| -rw-r--r-- | internal/client/ui/core/core.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/client/ui/core/core.go b/internal/client/ui/core/core.go index 36c2b0f..c7b3ca4 100644 --- a/internal/client/ui/core/core.go +++ b/internal/client/ui/core/core.go @@ -189,6 +189,9 @@ func (m *Model) updateNotConnected(msg tea.Msg) tea.Cmd { switch msg := msg.(type) { case gateway.ConnectionEstablished: state.UserID = (*snowflake.ID)(&msg) + state.ReceivedData = false + state.ReceivedNetworks = false + state.AskedForNotifs = false m.connected = true m.timeout = initialTimeout @@ -257,6 +260,11 @@ func (m *Model) updateConnected(msg tea.Msg) tea.Cmd { m.memberList.SetWidth(sidebarWidth) m.chat.SetWidth(chatWidth) + if state.ReceivedData && state.ReceivedNetworks && !state.AskedForNotifs { + state.AskedForNotifs = true + state.AskForNotifs() + } + switch msg := msg.(type) { case ui.QuitMsg: data := state.JsonUserData() @@ -335,6 +343,9 @@ func (m *Model) updateConnected(msg tea.Msg) tea.Cmd { case *packet.TrustInfo: state.UpdateTrusteds(msg) + case *packet.NotificationsInfo: + state.UpdateNotifications(msg) + case ui.BanReasonPopupMsg: popup := banreason.New(msg.User, msg.Network) m.banReasonPopup = &popup @@ -693,6 +704,10 @@ func (m *Model) HasPopup() bool { func calculateNotifications() { for networkId := range state.State.Networks { for _, frequency := range state.State.Frequencies[networkId] { + if _, ok := state.State.Messages[frequency.ID]; !ok { + continue + } + pings, hasNotif := getFrequencyNotification(networkId, frequency.ID) if hasNotif { state.State.Notifications[frequency.ID] = pings |
