mirror of
https://github.com/yattee/yattee.git
synced 2026-10-27 15:07:18 +00:00
Fence stale feed results and stop guessing at unknown account state
Signing in again keeps the account ID and the context, so a request already in flight under the previous credential could land afterwards and write that user's private feed back into the cache and onto disk. Feed results now carry the account they were requested for and are dropped if it has moved. An account with no recorded status was reported as "sign in required". While the identity scope is unresolved nothing can read the Keychain under the right scope, so that is the absence of an answer, not one — on a tokenless or first-seen Apple account it told users with working logins to sign in again and dropped reads to local data. It is now a state of its own. Transport failures mark the account unreachable instead of leaving it "signed in", which is what the documented local read fallback keys on. Neither that nor a rejection is overwritten by the Keychain-based refresh any more: only the server can clear what the server said. Disabling sync deliberately does not rewrite Keychain items to local. That means deleting them, and deleting a synchronizable item propagates to every device — "stop syncing this login" would sign the user out elsewhere, which is not what the toggle says. The reasoning is recorded at the call site.
This commit is contained in:
@@ -9,6 +9,10 @@ import Foundation
|
||||
|
||||
/// Why the selected context cannot be used at the moment.
|
||||
enum DataContextUnavailability: Hashable, Sendable {
|
||||
/// Nothing is known yet: the Apple account the credentials are keyed by is
|
||||
/// still being established, so the Keychain cannot be read under the right
|
||||
/// scope. Never render this as "sign in required".
|
||||
case checking
|
||||
/// The account exists but its instance hasn't arrived from iCloud yet.
|
||||
case instancePending
|
||||
/// The account's instance has been switched off. The selection is kept —
|
||||
@@ -105,6 +109,7 @@ final class DataContextValidator {
|
||||
|
||||
switch accountsManager.status(for: id) {
|
||||
case .signedIn: return .valid
|
||||
case .checking: return .temporarilyUnavailable(.checking)
|
||||
case .credentialMissing: return .temporarilyUnavailable(.credentialMissing)
|
||||
case .credentialRejected: return .temporarilyUnavailable(.credentialRejected)
|
||||
case .unreachable: return .temporarilyUnavailable(.unreachable)
|
||||
|
||||
@@ -38,7 +38,22 @@ final class InvidiousSubscriptionProvider: SubscriptionProvider {
|
||||
return
|
||||
}
|
||||
|
||||
guard case APIError.unauthorized = error else { return }
|
||||
// A server that cannot be reached says nothing about the credential.
|
||||
// Recorded all the same: the account has to stop reporting itself as
|
||||
// usable, or reads never fall back and the user is shown failures
|
||||
// instead of local data.
|
||||
switch error {
|
||||
case APIError.timeout, APIError.noConnection:
|
||||
accountsManager.setStatus(.unreachable, for: account.id)
|
||||
return
|
||||
case APIError.cancelled:
|
||||
return
|
||||
case APIError.unauthorized:
|
||||
break
|
||||
default:
|
||||
return
|
||||
}
|
||||
|
||||
guard accountsManager.instance(for: account)?.usesBasicAuth == false else { return }
|
||||
|
||||
accountsManager.setStatus(.credentialRejected, for: account.id)
|
||||
|
||||
@@ -38,7 +38,22 @@ final class PipedSubscriptionProvider: SubscriptionProvider {
|
||||
return
|
||||
}
|
||||
|
||||
guard case APIError.unauthorized = error else { return }
|
||||
// A server that cannot be reached says nothing about the credential.
|
||||
// Recorded all the same: the account has to stop reporting itself as
|
||||
// usable, or reads never fall back and the user is shown failures
|
||||
// instead of local data.
|
||||
switch error {
|
||||
case APIError.timeout, APIError.noConnection:
|
||||
accountsManager.setStatus(.unreachable, for: account.id)
|
||||
return
|
||||
case APIError.cancelled:
|
||||
return
|
||||
case APIError.unauthorized:
|
||||
break
|
||||
default:
|
||||
return
|
||||
}
|
||||
|
||||
guard accountsManager.instance(for: account)?.usesBasicAuth == false else { return }
|
||||
|
||||
accountsManager.setStatus(.credentialRejected, for: account.id)
|
||||
|
||||
Reference in New Issue
Block a user