mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +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) {
|
func setCurrent(_ account: Account! = nil) {
|
||||||
guard account != current else {
|
guard account != current else {
|
||||||
return
|
return
|
||||||
|
@ -14,7 +14,7 @@ final class InstancesModel: ObservableObject {
|
|||||||
return InstancesModel.find(id)
|
return InstancesModel.find(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastUsed: Instance? {
|
static var lastUsed: Instance? {
|
||||||
guard let id = Defaults[.lastInstanceID] else {
|
guard let id = Defaults[.lastInstanceID] else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ final class InstancesManifest: Service, ObservableObject {
|
|||||||
guard let country = country else {
|
guard let country = country else {
|
||||||
accounts.publicAccount = nil
|
accounts.publicAccount = nil
|
||||||
if asCurrent {
|
if asCurrent {
|
||||||
accounts.setCurrent(nil)
|
accounts.configureAccount()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -174,12 +174,8 @@ struct YatteeApp: App {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if Defaults[.lastAccountID] != "public",
|
if Defaults[.lastAccountID] != "public" {
|
||||||
let account = accounts.lastUsed ??
|
accounts.configureAccount()
|
||||||
instances.lastUsed?.anonymousAccount ??
|
|
||||||
InstancesModel.all.first?.anonymousAccount
|
|
||||||
{
|
|
||||||
accounts.setCurrent(account)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let countryOfPublicInstances = Defaults[.countryOfPublicInstances]
|
let countryOfPublicInstances = Defaults[.countryOfPublicInstances]
|
||||||
|
Loading…
Reference in New Issue
Block a user