fix(fronts): use the single-front replace endpoint for co-front changes - #56
Merged
Conversation
Adds POST /v1/fronts/{id}/replace and routes every "change who is in this one
front" path through it.
Adding or removing a member from a co-front used to PATCH the front's member
list in place. That has two problems the new endpoint exists to solve: editing
the list rewrites one row, so each member's stint stops being its own history
entry, and the change carries no notion of a boundary between the old
composition and the new. Replacing ends the old front and opens its
replacement in one transaction, keeping per-member history intact, and leaves
every other open front alone - which matters when the member being removed is
in one co-front and someone unrelated is fronting in another.
Six call sites move over: add-to-front and remove-from-front on both the
members list and the member profile, remove-from-front on Home, and the
offline queue's replay of a removal (which passes the queued removal time as
the boundary, so a switch made offline lands where the user actually made it).
Removing the last member of a front still ends it rather than replacing it;
replace requires a non-empty member list, and ending is what that action means.
Separately, "set as sole fronter" ended every open front in a loop and then
created the new one, which is a stop notification per front followed by a
start. It is now a single create with replace_fronts, which the server does in
one transaction and reports as one aggregated change.
Not changed: the switch sheet and the quick-switch carousel already issue a
single create with replace_fronts, and the server takes one before/after
snapshot around it, so those were already emitting one notification.
SiteRelEnby
enabled auto-merge
August 3, 2026 04:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Client side of the server's new
POST /v1/fronts/{id}/replace.What was wrong
Adding or removing a member from a co-front PATCHed the front's member list in place. Two problems:
What changed
Six call sites now use replace, which ends the old front and opens its replacement in one transaction, keeps per-member history, and leaves every other open front untouched:
The offline replay passes the queued removal time as the boundary, so a removal made offline lands in history where the user actually made it, not when the queue happened to drain.
Removing the last member of a front still ends it rather than replacing it. Replace requires a non-empty member list, and ending is what that action means.
Separately: "set as sole fronter"
This ended every open front in a loop and then created the new one - a stop notification per front, then a start. It is now a single create with
replace_fronts, which the server does in one transaction and reports as one aggregated change.What did not need changing
The switch sheet and the quick-switch carousel already issue a single create with
replace_fronts, and the server takes one before/after snapshot around it, so those were already emitting a single notification. I checked before touching them.Testing
:app:assemblePlayRelease+:app:testPlayReleaseUnitTestgreen. Needs a device pass against a server with the endpoint, ideally with a notification channel set up so the notification count is observable: