Refactor: use relay-provided member lists as source of truth #191
Reference in New Issue
Block a user
Delete Branch "nayan9617/flotilla:dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #85
Changes:
This simplifies membership handling and avoids inconsistencies caused by replaying global join/leave events.
Hey @nayan9617, could you please update the PR? It currently has merge conflicts.
@userAdityaa yupp, resolved!
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}Don't fail here, just skip the space membership step if there's no member list.
@@ -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>Use "space" instead of "relay"
@@ -183,2 +183,3 @@<Icon icon={UserRounded} />View Members ({$members.length}){#if $members === undefined}View Members (unavailable)Remove
(unavailable)@@ -769,0 +770,4 @@// Cannot add members without access to the member listif (spaceMembers === undefined) {return "Member list not available from this relay"}Don't fail hard, just send all pubkeys (change the filter line to
.filter(pubkey => spaceMembers && !spaceMembers.includes(pubkey)))@@ -808,36 +809,51 @@ export const deriveOtherRooms = (url: string) =>// Space/room membershipsLet'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:Same thing in deriveRoomMemberList (which should be deriveRoomMembers).
@@ -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]},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]},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({Remove the comment
@@ -65,3 +65,3 @@throttled(800, profiles),throttled(800, handlesByNip05),throttled(800, deriveSpaceMembers(url || "")),throttled(800, deriveRelayMemberList(url || "")),Remove the comment
@@ -259,3 +259,3 @@at: at || now(),element: element!,filters: [{kinds: [MESSAGE, RELAY_ADD_MEMBER]}],filters: [{kinds: [...CONTENT_KINDS, MESSAGE]}],This is incorrect, it should be the way it was before.
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) =>This should be renamed to deriveSpaceMembers since it returns a svelte store, not the value itself.
@hodlbod Rebased and renamed to deriveSpaceMembers across all call sites. Ready for final review.
Thanks, looks good!