This commit is contained in:
Bryan1029384756
2026-04-18 15:41:51 -05:00
parent 938df217f4
commit 593eaba82e
47 changed files with 3539 additions and 212 deletions

View File

@@ -82,7 +82,11 @@ export const getAllReadStates = query({
},
});
// Get the latest message timestamp per channel (used by Sidebar)
// Get the latest message timestamp per channel (used by Sidebar).
// Also surfaces `messageId` and `senderId` so the notification
// observer can detect genuinely new messages (not just timestamp
// ticks from edits) and suppress notifications for the user's own
// sends without an extra round-trip.
export const getLatestMessageTimestamps = query({
args: {
channelIds: v.array(v.id("channels")),
@@ -91,6 +95,8 @@ export const getLatestMessageTimestamps = query({
v.object({
channelId: v.id("channels"),
latestTimestamp: v.number(),
messageId: v.optional(v.id("messages")),
senderId: v.optional(v.id("userProfiles")),
})
),
handler: async (ctx, args) => {
@@ -105,6 +111,8 @@ export const getLatestMessageTimestamps = query({
results.push({
channelId,
latestTimestamp: Math.floor(latestMsg._creationTime),
messageId: latestMsg._id,
senderId: latestMsg.senderId,
});
}
}