Refuse to repair a context that is not this identity's

Foreground activation repairs a selection whose account this device
knows was deleted. The check for whether that is safe was the identity
scope being resolved, which it already is in the window between an Apple
account change moving the namespace and the reload refilling memory —
so the repair weighed the previous identity's selection against the
previous identity's tombstones and announced the result to a user who
had not been shown an account yet. Fenced on the loaded namespace, the
same way saves are.

Three smaller things around the same theme:

- The destination rows forgot their membership answers on a credential
  or account change but not on an instance change, which adds a row to
  the picker while it is open. Unknown reads as unsubscribed, so that
  row offered to subscribe a channel the account already has.

- The subscriptions settings count applied whatever the fetch returned.
  A selection change is fenced by the service's provider generation, but
  the fallback to local is driven by availability and announces nothing,
  so the context is captured before the fetch and rechecked after it.

- Deleting a source from the browser runs the same cascade as deleting
  it from Settings, and was the one dialog left that did not say the
  logins go with it.
This commit is contained in:
Arkadiusz Fal
2026-09-04 23:59:27 +02:00
parent fbeae586b0
commit f44c1d91c3
5 changed files with 85 additions and 1 deletions

View File

@@ -353,6 +353,14 @@ final class AccountsManager {
/// - Returns: `true` when the selection actually moved.
@discardableResult
func correctContextIfAccountDeleted() -> Bool {
// The namespace moved and the reload has not refilled memory yet, so
// the selection and the tombstones weighed against each other here both
// belong to the previous identity. Fenced on the loaded namespace for
// the same reason `save()` is: acting on that state repairs — and
// announces — a choice the identity being switched to never made. The
// reload replaces both sides, and the next activation asks again.
guard loadedNamespace == namespace else { return false }
guard case let .account(id) = storedContext.context else { return false }
guard deletedAccountIDs.contains(id) else { return false }