mirror of
https://github.com/Kyren223/eko.git
synced 2026-07-16 16:41:03 +00:00
Server now also sends the last_read column to the client so the client
so the client can use it to persist notifications
This commit is contained in:
@@ -260,6 +260,9 @@ func SendUserDatUpdate() {
|
||||
|
||||
func UpdateNotifications(info *packet.NotificationsInfo) {
|
||||
for i := 0; i < len(info.Source); i++ {
|
||||
lastRead := snowflake.ID(info.LastRead[i])
|
||||
State.LastReadMessages[info.Source[i]] = &lastRead
|
||||
|
||||
ping := info.Pings[i]
|
||||
if ping != nil {
|
||||
State.Notifications[info.Source[i]] = int(*ping)
|
||||
|
||||
@@ -244,8 +244,9 @@ func (m *SetLastReadMessages) Type() PacketType {
|
||||
}
|
||||
|
||||
type NotificationsInfo struct {
|
||||
Source []snowflake.ID
|
||||
Pings []*int64
|
||||
Source []snowflake.ID
|
||||
LastRead []int64
|
||||
Pings []*int64
|
||||
}
|
||||
|
||||
func (m *NotificationsInfo) Type() PacketType {
|
||||
|
||||
@@ -148,7 +148,7 @@ permitted_frequencies AS (
|
||||
WHERE m.is_member = true AND (f.perms != 0 OR m.is_admin = true)
|
||||
)
|
||||
SELECT
|
||||
e.source_id,
|
||||
e.source_id, e.last_read,
|
||||
CASE
|
||||
WHEN COUNT(m.id) = 0 THEN NULL
|
||||
ELSE SUM(CASE WHEN (m.ping = 0 OR (m.ping = 1 AND pf.is_admin = true) OR m.ping = ?) THEN 1 ELSE 0 END)
|
||||
@@ -173,11 +173,13 @@ func getNotifications(ctx context.Context, userId snowflake.ID) (packet.Notifica
|
||||
var items packet.NotificationsInfo
|
||||
for rows.Next() {
|
||||
var source *snowflake.ID
|
||||
var lastRead *int64
|
||||
var pings *int64
|
||||
if err := rows.Scan(&source, &pings); err != nil {
|
||||
if err := rows.Scan(&source, &lastRead, &pings); err != nil {
|
||||
return packet.NotificationsInfo{}, err
|
||||
}
|
||||
items.Source = append(items.Source, *source)
|
||||
items.LastRead = append(items.LastRead, *lastRead)
|
||||
items.Pings = append(items.Pings, pings)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user