Refactor: use relay-provided member lists as source of truth #191

Merged
hodlbod merged 8 commits from nayan9617/flotilla:dev into dev 2026-04-13 21:12:51 +00:00
Contributor

Fixes #85

Changes:

  1. Replace deriveSpaceMembers / deriveRoomMembers with relay-based lists
  2. Remove global ADD/REMOVE sync from syncSpace
  3. Fallback to user-specific add/remove history when member list is unavailable
  4. Add explicit UI state when member list is missing

This simplifies membership handling and avoids inconsistencies caused by replaying global join/leave events.

Fixes #85 ## Changes: 1. Replace deriveSpaceMembers / deriveRoomMembers with relay-based lists 2. Remove global ADD/REMOVE sync from syncSpace 3. Fallback to user-specific add/remove history when member list is unavailable 4. Add explicit UI state when member list is missing This simplifies membership handling and avoids inconsistencies caused by replaying global join/leave events.
nayan9617 added 2 commits 2026-04-11 16:24:44 +00:00
Collaborator

Hey @nayan9617, could you please update the PR? It currently has merge conflicts.

Hey [@nayan9617](https://gitea.coracle.social/nayan9617), could you please update the PR? It currently has merge conflicts.
nayan9617 added 1 commit 2026-04-11 17:33:41 +00:00
Author
Contributor

@userAdityaa yupp, resolved!

@userAdityaa yupp, resolved!
hodlbod reviewed 2026-04-11 17:43:28 +00:00
hodlbod left a comment
Owner

I have a few comments to start with, can you also try to avoid re-ordering the stuff in core/state? It makes it quite hard to review in detail. Also make sure to rebase on dev and fix conflicts.

I have a few comments to start with, can you also try to avoid re-ordering the stuff in core/state? It makes it quite hard to review in detail. Also make sure to rebase on dev and fix conflicts.
@@ -59,0 +63,4 @@
message: "Cannot add members: space member list not available from this relay",
})
return
}
Owner

Don't fail here, just skip the space membership step if there's no member list.

Don't fail here, just skip the space membership step if there's no member list.
hodlbod marked this conversation as resolved
@@ -152,1 +115,3 @@
</div>
{#if $members === undefined}
<div class="card2 bg-base-200 p-4">
<span class="text-error">Member list not available from this relay</span>
Owner

Use "space" instead of "relay"

Use "space" instead of "relay"
hodlbod marked this conversation as resolved
@@ -183,2 +183,3 @@
<Icon icon={UserRounded} />
View Members ({$members.length})
{#if $members === undefined}
View Members (unavailable)
Owner

Remove (unavailable)

Remove `(unavailable)`
@@ -769,0 +770,4 @@
// Cannot add members without access to the member list
if (spaceMembers === undefined) {
return "Member list not available from this relay"
}
Owner

Don't fail hard, just send all pubkeys (change the filter line to .filter(pubkey => spaceMembers && !spaceMembers.includes(pubkey)))

Don't fail hard, just send all pubkeys (change the filter line to `.filter(pubkey => spaceMembers && !spaceMembers.includes(pubkey))`)
hodlbod marked this conversation as resolved
@@ -808,36 +809,51 @@ export const deriveOtherRooms = (url: string) =>
// Space/room memberships
Owner

Let's just keep calling this getSpaceMembers. I was thinking of using the list directly, but it's more convenient to return the uniqe list of pubkeys. However, you might change the body to:

([event]) => uniq(getTagValues("member", event?.tags ?? []))

Same thing in deriveRoomMemberList (which should be deriveRoomMembers).

Let's just keep calling this `getSpaceMembers`. I was thinking of using the list directly, but it's more convenient to return the uniqe list of pubkeys. However, you might change the body to: ```typescript ([event]) => uniq(getTagValues("member", event?.tags ?? [])) ``` Same thing in deriveRoomMemberList (which should be deriveRoomMembers).
hodlbod marked this conversation as resolved
@@ -178,1 +177,3 @@
{kinds: [RELAY_REMOVE_MEMBER], "#p": [$pubkey], limit: 1},
// Keep current-user membership history so status replay stays deterministic.
{kinds: [RELAY_ADD_MEMBER], "#p": [$pubkey]},
{kinds: [RELAY_REMOVE_MEMBER], "#p": [$pubkey]},
Owner

Keep the limit, we want that

Keep the limit, we want that
@@ -197,1 +197,3 @@
{kinds: [ROOM_REMOVE_MEMBER], "#p": [$pubkey], "#h": [h], limit: 1},
// Keep current-user membership history so status replay stays deterministic.
{kinds: [ROOM_ADD_MEMBER], "#p": [$pubkey], "#h": [h]},
{kinds: [ROOM_REMOVE_MEMBER], "#p": [$pubkey], "#h": [h]},
Owner

Keep the limit, remove the comment

Keep the limit, remove the comment
@@ -298,3 +300,3 @@
const roomMemberKinds = [ROOM_DELETE, ROOM_JOIN, ROOM_LEAVE, ROOM_ADD_MEMBER, ROOM_REMOVE_MEMBER]
const roomDeleteKinds = [ROOM_DELETE, ROOM_JOIN, ROOM_LEAVE]
pullAndListen({
Owner

Remove the comment

Remove the comment
hodlbod marked this conversation as resolved
@@ -65,3 +65,3 @@
throttled(800, profiles),
throttled(800, handlesByNip05),
throttled(800, deriveSpaceMembers(url || "")),
throttled(800, deriveRelayMemberList(url || "")),
Owner

Remove the comment

Remove the comment
@@ -259,3 +259,3 @@
at: at || now(),
element: element!,
filters: [{kinds: [MESSAGE, RELAY_ADD_MEMBER]}],
filters: [{kinds: [...CONTENT_KINDS, MESSAGE]}],
Owner

This is incorrect, it should be the way it was before.

This is incorrect, it should be the way it was before.
nayan9617 added 1 commit 2026-04-11 18:03:02 +00:00
nayan9617 added 1 commit 2026-04-11 18:13:19 +00:00
hodlbod reviewed 2026-04-13 17:05:47 +00:00
hodlbod left a comment
Owner

Looks good, just one nitpick

Looks good, just one nitpick
@@ -810,3 +810,2 @@
const getSpaceMembers = (_url: string, events: TrustedEvent[]) => {
const members = new Set<string>()
export const getSpaceMembers = (url: string) =>
Owner

This should be renamed to deriveSpaceMembers since it returns a svelte store, not the value itself.

This should be renamed to deriveSpaceMembers since it returns a svelte store, not the value itself.
hodlbod marked this conversation as resolved
nayan9617 added 1 commit 2026-04-13 17:54:26 +00:00
nayan9617 added 1 commit 2026-04-13 18:20:42 +00:00
Author
Contributor

@hodlbod Rebased and renamed to deriveSpaceMembers across all call sites. Ready for final review.

@hodlbod Rebased and renamed to deriveSpaceMembers across all call sites. Ready for final review.
nayan9617 added 1 commit 2026-04-13 20:06:20 +00:00
hodlbod merged commit b46fd94578 into dev 2026-04-13 21:12:51 +00:00
Owner

Thanks, looks good!

Thanks, looks good!
Sign in to join this conversation.