Skip to content

fix(chat): keep a just-left group left when an older group feed lands - #1241

Merged
bmc08gt merged 1 commit into
mainfrom
fix/group-feed-stale-rejoin
Nov 9, 2026
Merged

bmc08gt merged 1 commit into
mainfrom
fix/group-feed-stale-rejoin

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Follows #1240, which fixed the join side of this race. A leave has the mirror problem.

Cause

  • ConversationController.leave and the roster .left path in applyRosterMembership call store.setMembership(false), which dropped the group's seat stamp.
  • A group feed requested before the leave still lists the group. ConversationStore.setGroupFeed(_:requestedAt:) then set joinedGroupIDs = joined ∪ seatedSince, so the user was a member again.
  • applyGroupFeed passed the feed to replaceGroupFeed, which writes membership=true for every group it is given, so the DB kept it until the next fresh feed.

Fix

  • setMembership stamps every change, join or leave, with a generation.
  • In setGroupFeed, for groups changed after the mark, local membership wins: a join stays joined and out of departed; a leave stays un-joined even though the feed lists it. The row stays in the store, since the screen the user left from renders its gate from it.
  • applyGroupFeed passes only groups the store still counts as joined to replaceGroupFeed, so the DB does not record membership=true for a just-left group.
  • A feed requested after the change is trusted fully: a group it lists is joined again.

Follows #1240. Leaving a group while a group feed was in flight was
undone when that feed landed: `setMembership(false)` dropped the group's
stamp, so `setGroupFeed` saw the stale listing, marked the user joined
again, and `replaceGroupFeed` wrote membership=true to the DB.

The stamp now records every membership change, join or leave. For a
group changed after a feed's `requestedAt` mark, local membership wins:
a join is kept, a leave stays un-joined. The left group's row is kept so
the screen the user left from can still render its gate, and the
controller records only still-joined groups through `replaceGroupFeed`.
A feed requested after the change is trusted fully.
@bmc08gt bmc08gt self-assigned this Nov 9, 2026
@bmc08gt
bmc08gt merged commit 9ce7d78 into main Nov 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant