mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 00:08:21 +00:00
Switch to private account on selecting to not use public location (#212)
This commit is contained in:
parent
02a27b4f95
commit
9cb6ff64ff
@ -54,6 +54,15 @@ final class AccountsModel: ObservableObject {
|
||||
)
|
||||
}
|
||||
|
||||
func configureAccount() {
|
||||
if let account = lastUsed ??
|
||||
InstancesModel.lastUsed?.anonymousAccount ??
|
||||
InstancesModel.all.first?.anonymousAccount
|
||||
{
|
||||
setCurrent(account)
|
||||
}
|
||||
}
|
||||
|
||||
func setCurrent(_ account: Account! = nil) {
|
||||
guard account != current else {
|
||||
return
|
||||
|
@ -14,7 +14,7 @@ final class InstancesModel: ObservableObject {
|
||||
return InstancesModel.find(id)
|
||||
}
|
||||
|
||||
var lastUsed: Instance? {
|
||||
static var lastUsed: Instance? {
|
||||
guard let id = Defaults[.lastInstanceID] else {
|
||||
return nil
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ final class InstancesManifest: Service, ObservableObject {
|
||||
guard let country = country else {
|
||||
accounts.publicAccount = nil
|
||||
if asCurrent {
|
||||
accounts.setCurrent(nil)
|
||||
accounts.configureAccount()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -174,12 +174,8 @@ struct YatteeApp: App {
|
||||
}
|
||||
#endif
|
||||
|
||||
if Defaults[.lastAccountID] != "public",
|
||||
let account = accounts.lastUsed ??
|
||||
instances.lastUsed?.anonymousAccount ??
|
||||
InstancesModel.all.first?.anonymousAccount
|
||||
{
|
||||
accounts.setCurrent(account)
|
||||
if Defaults[.lastAccountID] != "public" {
|
||||
accounts.configureAccount()
|
||||
}
|
||||
|
||||
let countryOfPublicInstances = Defaults[.countryOfPublicInstances]
|
||||
|
Loading…
Reference in New Issue
Block a user