fix off-by-one error in visible messages for current channel

This commit is contained in:
2026-04-07 17:06:38 -04:00
parent c9cdc9cd37
commit 83661afd18
3 changed files with 3 additions and 6 deletions
+2 -1
View File
@@ -277,7 +277,8 @@ export const subscribe_to_channel = spacetimedb.reducer(
(ctx, { channelId }) => {
const hwm = ctx.db.channel_high_water_mark.channel_id.find(channelId);
const currentMax = hwm ? hwm.last_seq_id : 0n;
const earliest = currentMax > 100n ? currentMax - 100n : 0n;
// Sync exactly 100 messages (e.g. if max is 100, we want 1-100 inclusive, so earliest is 1)
const earliest = currentMax > 99n ? currentMax - 99n : 1n;
const existing = ctx.db.channel_subscription.identity.find(ctx.sender);
if (existing) {