summaryrefslogtreecommitdiff
path: root/internal/client/ui/core/core.go
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2025-02-02 19:23:50 +0200
committerKyren223 <Kyren223@proton.me>2025-02-02 19:23:50 +0200
commitc77ac77e78268bc2f4265a872b213d4300b3eb66 (patch)
tree1c2f1be6f2c7a724486d24b0c83014032e761f49 /internal/client/ui/core/core.go
parenta1c20cbfc5a90642e486132d4673646342df13fd (diff)
Added support for offline notifications where the server calculates them
and sends the info to the client when it connects
Diffstat (limited to 'internal/client/ui/core/core.go')
-rw-r--r--internal/client/ui/core/core.go15
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