diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-02-06 16:33:16 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-02-06 16:33:16 +0200 |
| commit | 3c05ff093739ca02e6ed2e1e736b59360d111e1e (patch) | |
| tree | 41daa663ed0589ca810cc2faf5ca533219f7a2bb /internal/client/ui/core/core.go | |
| parent | f10f8396cca77dfa33c2c2d45063a4817b5612e5 (diff) | |
Added notifications display in user signals
Diffstat (limited to 'internal/client/ui/core/core.go')
| -rw-r--r-- | internal/client/ui/core/core.go | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/internal/client/ui/core/core.go b/internal/client/ui/core/core.go index 60225d8..80f5d7a 100644 --- a/internal/client/ui/core/core.go +++ b/internal/client/ui/core/core.go @@ -687,7 +687,15 @@ func (m *Model) HasPopup() bool { } func calculateNotifications() { - // TODO: handle notifications for receiver id + for _, signal := range state.Data.Signals { + if _, ok := state.State.Messages[signal]; !ok { + continue + } + + pings := getSignalNotification(signal) + state.State.Notifications[signal] = pings + } + for networkId := range state.State.Networks { for _, frequency := range state.State.Frequencies[networkId] { if _, ok := state.State.Messages[frequency.ID]; !ok { @@ -740,3 +748,24 @@ func getFrequencyNotification(networkId, frequencyId snowflake.ID) (_ int, _ boo return pings, hasNotif } + +func getSignalNotification(signal snowflake.ID) int { + lastReadMsg := state.State.LastReadMessages[signal] + if lastReadMsg == nil { + return 0 + } + + btree := state.State.Messages[signal] + if btree == nil { + return 0 + } + + pings := 0 + + btree.AscendGreaterOrEqual(data.Message{ID: *lastReadMsg + 1}, func(item data.Message) bool { + pings++ + return pings <= 10 + }) + + return pings +} |
