mirror of
https://github.com/yattee/yattee.git
synced 2026-10-23 13:12:53 +00:00
An account whose source is gone was listed nowhere: `orphanedAccounts` had no readers, and the credential behind it could not be reached at all — `AppEnvironment.accountCredentialsManager(for:)` resolves the store from the account's instance, and an orphan has none. The new accounts screen lists them and removes them by account ID, asking every account-keyed store because the backend is no longer knowable. The pre-revamp instance-keyed item is deliberately left behind: identifying it needs the instance too. Deleting a source has always signed out and removed the accounts on it. Both confirmations now say so, and name them. The sign-in that files a credential against an account is now one implementation instead of a private method on the source editor, so the accounts screen and the new optional sign-in step after adding a source attach a login exactly as the editor does. Extracted verbatim — the identity-scope guard, the account re-resolve, the write-then-read-back and the rollback are what keep a half-written login from looking real. Signing out from the per-instance section now asks first, and both sign-out paths run one cascade rather than two copies of it.
36 lines
1.3 KiB
Swift
36 lines
1.3 KiB
Swift
//
|
|
// InstanceDeletionDisclosure.swift
|
|
// Yattee
|
|
//
|
|
// What deleting a source takes with it, said before it happens.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
/// Names the accounts an instance deletion would sign out and remove.
|
|
///
|
|
/// The cascade has always taken them; only the confirmation was silent about
|
|
/// it. Deleting a source the user set up months ago is otherwise the one action
|
|
/// in the app that quietly destroys a login.
|
|
enum InstanceDeletionDisclosure {
|
|
/// The accounts paragraph for the confirmation, or `nil` when the instance
|
|
/// has none and the plain "delete this?" question already says everything.
|
|
static func message(accountNames: [String]) -> String? {
|
|
guard !accountNames.isEmpty else { return nil }
|
|
|
|
let warning = String(localized: "sources.delete.accountsWarning \(accountNames.count)")
|
|
return ([warning] + accountNames).joined(separator: "\n")
|
|
}
|
|
|
|
@MainActor
|
|
static func message(for instance: Instance, in appEnvironment: AppEnvironment?) -> String? {
|
|
guard let appEnvironment else { return nil }
|
|
|
|
let names = appEnvironment.accountsManager
|
|
.accounts(forInstance: instance.id)
|
|
.map { appEnvironment.dataContextValidator.displayName(for: $0) }
|
|
|
|
return message(accountNames: names)
|
|
}
|
|
}
|