fix: realtime updates for room members and admins #178

Merged
hodlbod merged 1 commits from userAdityaa/flotilla:realtime-room-updates into dev 2026-04-09 21:05:31 +00:00
Collaborator

Description

Fixes live updates for room/member/admin changes by ensuring active room is always subscribed and membership/admin state is derived correctly from snapshots and deltas.

Related to: #144

Test Steps:

  1. Open two instances of app.flotilla.social in the same room.
  2. Add/remove members or admins in one browser.
  3. Confirm the other browser updates live without reload.
  4. Reload both, state should remain correct.

Recordings

### Description Fixes live updates for room/member/admin changes by ensuring active room is always subscribed and membership/admin state is derived correctly from snapshots and deltas. Related to: #144 ### Test Steps: 1. Open two instances of _**app.flotilla.social**_ in the same room. 2. Add/remove members or admins in one browser. 3. Confirm the other browser updates live without reload. 4. Reload both, state should remain correct. ### Recordings <video src="attachments/e600e461-9c90-4553-a604-0f1172c06588" title="Screen Recording 2026-04-09 at 2.00.06 AM.mov" controls></video>
userAdityaa marked the pull request as work in progress 2026-04-08 20:31:57 +00:00
Author
Collaborator

Two-part fix for room members, admins, and action items:

  • Sync: Always subscribe to the current room’s live events.
  • State: Compute lists by combining the latest snapshot with all add/remove events after it.

@hodlbod, does this approach look reasonable to you?

Two-part fix for room members, admins, and action items: * Sync: Always subscribe to the current room’s live events. * State: Compute lists by combining the latest snapshot with all add/remove events after it. @hodlbod, does this approach look reasonable to you?
userAdityaa marked the pull request as ready for review 2026-04-08 20:50:29 +00:00
hodlbod reviewed 2026-04-09 19:55:51 +00:00
hodlbod left a comment
Owner

The sync changes look good, but I'm not so sure about core/state. I'm having a hard time telling what's changed there other than moving logic around. Is there anything in particular different functionality-wise?

The sync changes look good, but I'm not so sure about core/state. I'm having a hard time telling what's changed there other than moving logic around. Is there anything in particular different functionality-wise?
Author
Collaborator

The sync changes look good, but I'm not so sure about core/state. I'm having a hard time telling what's changed there other than moving logic around. Is there anything in particular different functionality-wise?

The main real change in core/state is how membership is computed (a new function getMembershipState is added). It now treats the full members event as a starting point and then applies later add/remove events on top, so member lists and pending join requests stay up to date in realtime.

Other than that, most of the state diff is just reorganizing the logic.

> The sync changes look good, but I'm not so sure about core/state. I'm having a hard time telling what's changed there other than moving logic around. Is there anything in particular different functionality-wise? The main real change in `core/state` is how membership is computed (a new function `getMembershipState` is added). It now treats the full members event as a starting point and then applies later add/remove events on top, so member lists and pending join requests stay up to date in realtime. Other than that, most of the state diff is just reorganizing the logic.
Owner

Got it, would you mind making that change without reorganizing the logic? The new function takes too many parameters to be easy to understand. Smaller helper functions might be better, or just duplicate the logic everywhere it's needed.

Got it, would you mind making that change without reorganizing the logic? The new function takes too many parameters to be easy to understand. Smaller helper functions might be better, or just duplicate the logic everywhere it's needed.
Author
Collaborator

Thanks @hodlbod for the feedback, I reworked this to keep the logic in place rather than routing it through the generic helper. The membership behavior change is still there, but the code now follows the original structure much more closely and avoids the extra abstraction.

Thanks @hodlbod for the feedback, I reworked this to keep the logic in place rather than routing it through the generic helper. The membership behavior change is still there, but the code now follows the original structure much more closely and avoids the extra abstraction.
hodlbod requested changes 2026-04-09 20:43:37 +00:00
hodlbod left a comment
Owner

Great, that's much clearer, thanks.

Now I'm going to ask you to go back again 😂. I think what we need here is a getRoomMembers(url, h, events) function that can be called within deriveRoomMembers and deriveSpaceActionItems. I wouldn't mind a getSpaceMembers(url, events) function as well. That will be much clearer than putting both into the same function.

Great, that's much clearer, thanks. Now I'm going to ask you to go back again 😂. I think what we need here is a `getRoomMembers(url, h, events)` function that can be called within deriveRoomMembers and deriveSpaceActionItems. I wouldn't mind a `getSpaceMembers(url, events)` function as well. That will be much clearer than putting both into the same function.
Author
Collaborator

I just created those 🥲, but then figured it’d be better to integrate them into the existing function. I’ll push the changes shortly.

I just created those 🥲, but then figured it’d be better to integrate them into the existing function. I’ll push the changes shortly.
Author
Collaborator

@hodlbod I’ve added getRoomMembers and getSpaceMembers helpers, and now both deriveRoomMembers and deriveSpaceActionItems use getRoomMembers directly.

Let me know if you’d like any further tweaks!

@hodlbod I’ve added `getRoomMembers` and `getSpaceMembers` helpers, and now both `deriveRoomMembers` and `deriveSpaceActionItems` use `getRoomMembers` directly. Let me know if you’d like any further tweaks!
hodlbod added 1 commit 2026-04-09 21:05:15 +00:00
hodlbod force-pushed realtime-room-updates from 190e9eb889 to 6fb5011830 2026-04-09 21:05:15 +00:00 Compare
Owner

Looks great, thank you!

Looks great, thank you!
hodlbod merged commit 1d5f91fb6c into dev 2026-04-09 21:05:31 +00:00
hodlbod deleted branch realtime-room-updates 2026-04-09 21:05:31 +00:00
Sign in to join this conversation.