Skip to content

Sign out only after the local Anisette choice is saved - #317

Merged
parawanderer merged 2 commits into
mainfrom
fix/defer-signout-after-anisette-upgrade
Nov 23, 2026
Merged

parawanderer merged 2 commits into
mainfrom
fix/defer-signout-after-anisette-upgrade

Conversation

@parawanderer

@parawanderer parawanderer commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

MapsActivity.offerLocalAnisetteUpgradeIfDue chained saved.andThen(this.userAuthRepo.clearUser()). clearUser() is built on RxDataStore.updateDataAsync, which launches its write when called, not when subscribed, so the session was cleared while the chain was being built. If saving the choice then failed, the user was already signed out while the activity stayed on the map, and the next launch went to sign-in still set to the server.

Adds RxFlows.onlyAfter(first, () -> then), which creates then only once first has completed, and uses it for that sign-out. This was the only DataStore write chained after another step in app/src/main/java; I checked every updateDataAsync caller.

Found by @lazzurs in #315.

Verified:

  • RxFlowsTest has three new JVM tests. They use a stand-in that writes when called, as updateDataAsync does, and assert that the sign-out does not start before the save completes, never starts when the save fails, and does nothing until subscribed.
  • Negative control: with onlyAfter changed back to first.andThen(then.get()), all three fail.
  • :app:testDebugUnitTest: 574 tests, 0 failures.

Not covered: nothing stops a bare andThen(repo.clearUser()) being written at a call site again. That would need an Espresso test against MapsActivity with a fake settings repository.

🤖 Generated with Claude Code

clearUser() is built on RxDataStore.updateDataAsync, which starts its write when called rather
than when subscribed. Passed straight to andThen, it cleared the session while the chain was
being built, so accepting the upgrade signed the user out even if saving the choice failed.
Defer it so it runs after the save completes.

Found by lazzurs while working on #315.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RxFlows.onlyAfter(first, () -> then) creates `then` only once `first` has completed. MapsActivity
uses it for the local Anisette sign-out. The tests stand in for a DataStore write with one that
writes when called, and fail with the old `first.andThen(then)`: checked by putting it back, and
all three new tests went red.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@parawanderer
parawanderer merged commit f868821 into main Nov 23, 2026
4 checks passed
lazzurs pushed a commit to lazzurs/OpenTagViewer that referenced this pull request Nov 23, 2026
parawanderer#317 added RxFlows.onlyAfter for the same eager-DataStore trap this
branch worked around with Completable.defer. Settings' sign-out and
ThisPhonesTagData's three steps now use it, so there is one way to
write "only after" rather than two. AGENTS.md rule 23 points at the
helper instead of describing a second convention.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
Android Build — 58ed7c30 Deployed Nov 23, 2026 by parawanderer via build #421
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