Compare commits

...

2 Commits

Author SHA1 Message Date
Sofiyan_07 f7632ed560 merge upstream 2026-04-15 22:37:09 +00:00
bhavishy2801 132c7f031b fix: remove deleted rooms from space navigation after refresh
## Summary

This PR fixes a bug where deleting a room succeeded on the relay, but the room could still appear in space navigation (including after refresh).

Fixes #194.

## Root Cause

Room list derivation did not consistently treat delete events as authoritative in edge cases:
- Delete timestamp aggregation could involve an undefined prior value.
- Room meta events with the same second-level timestamp as a delete event were still considered active.

## Changes

- Updated room delete timestamp aggregation logic to handle first delete event safely.
- Updated room filtering condition so a room is excluded when its meta timestamp is less than or equal to the delete timestamp.
- This ensures deleted rooms are not shown in navigation immediately or after reload.

## Validation

- `pnpm run check` passed.
- `pnpm run lint` passed.

## Testing

- [x] In a NIP-29 space, create a temporary room.
- [x] Delete the room from room details.
- [x] Confirm it disappears from navigation immediately.
- [x] Hard refresh and confirm it does not reappear.
- [x] Reopen app/session and confirm it remains absent.
- [x] Repeat by creating/deleting another room quickly (same-minute timestamp edge case).
2026-04-14 15:43:49 +00:00
+8 -2
View File
@@ -615,7 +615,12 @@ export const roomsByUrl = derived(roomMetaEventsByIdByUrl, roomMetaEventsByIdByU
for (const event of deleteEvents) { for (const event of deleteEvents) {
for (const h of getTagValues("h", event.tags)) { for (const h of getTagValues("h", event.tags)) {
deletedByH.set(h, max([deletedByH.get(h), event.created_at])) const deletedAt = deletedByH.get(h)
deletedByH.set(
h,
deletedAt === undefined ? event.created_at : max([deletedAt, event.created_at]),
)
} }
} }
@@ -623,8 +628,9 @@ export const roomsByUrl = derived(roomMetaEventsByIdByUrl, roomMetaEventsByIdByU
for (const event of metaEvents) { for (const event of metaEvents) {
const meta = tryCatch(() => readRoomMeta(event)) const meta = tryCatch(() => readRoomMeta(event))
const deletedAt = meta ? deletedByH.get(meta.h) : undefined
if (!meta || gt(deletedByH.get(meta.h), meta.event.created_at)) { if (!meta || (deletedAt !== undefined && !gt(meta.event.created_at, deletedAt))) {
continue continue
} }