mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Use separate defaults keys for instances and accounts
This commit is contained in:
@@ -111,7 +111,7 @@ struct AccountFormView: View {
|
||||
return
|
||||
}
|
||||
|
||||
let account = instances.addAccount(instance: instance, name: name.serializationSafe, sid: sid)
|
||||
let account = instances.addAccount(instance: instance, name: name, sid: sid)
|
||||
selectedAccount?.wrappedValue = account
|
||||
|
||||
dismiss()
|
||||
@@ -120,7 +120,7 @@ struct AccountFormView: View {
|
||||
private var validator: AccountValidator {
|
||||
AccountValidator(
|
||||
url: instance.url,
|
||||
account: Instance.Account(url: instance.url, sid: sid),
|
||||
account: Instance.Account(instanceID: instance.id, url: instance.url, sid: sid),
|
||||
id: $sid,
|
||||
valid: $valid,
|
||||
validated: $validated
|
||||
|
@@ -12,6 +12,7 @@ struct AccountSettingsView: View {
|
||||
var body: some View {
|
||||
HStack {
|
||||
Text(account.description)
|
||||
|
||||
Spacer()
|
||||
|
||||
HStack {
|
||||
@@ -23,7 +24,7 @@ struct AccountSettingsView: View {
|
||||
isPresented: $presentingRemovalConfirmationDialog
|
||||
) {
|
||||
Button("Remove", role: .destructive) {
|
||||
instances.removeAccount(instance: instance, account: account)
|
||||
instances.removeAccount(account)
|
||||
}
|
||||
}
|
||||
#if os(macOS)
|
||||
|
@@ -15,12 +15,12 @@ struct InstanceDetailsSettingsView: View {
|
||||
var body: some View {
|
||||
List {
|
||||
Section(header: Text("Accounts")) {
|
||||
ForEach(instance.accounts) { account in
|
||||
ForEach(instances.accounts(instanceID)) { account in
|
||||
Text(account.description)
|
||||
#if !os(tvOS)
|
||||
.swipeActions(edge: .trailing, allowsFullSwipe: false) {
|
||||
Button("Remove", role: .destructive) {
|
||||
instances.removeAccount(instance: instance, account: account)
|
||||
instances.removeAccount(account)
|
||||
accountsChanged.toggle()
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,14 @@ struct InstancesSettingsView: View {
|
||||
instancesModel.find(selectedInstanceID)
|
||||
}
|
||||
|
||||
var accounts: [Instance.Account] {
|
||||
guard selectedInstance != nil else {
|
||||
return []
|
||||
}
|
||||
|
||||
return instancesModel.accounts(selectedInstanceID)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
#if os(iOS)
|
||||
@@ -74,16 +82,17 @@ struct InstancesSettingsView: View {
|
||||
}
|
||||
|
||||
if let instance = selectedInstance {
|
||||
if instance.accounts.isEmpty {
|
||||
if accounts.isEmpty {
|
||||
Text("You have no accounts for this instance")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
} else {
|
||||
Text("Accounts")
|
||||
List(selection: $selectedAccount) {
|
||||
ForEach(instance.accounts) { account in
|
||||
ForEach(accounts) { account in
|
||||
AccountSettingsView(instance: instance, account: account,
|
||||
selectedAccount: $selectedAccount)
|
||||
.tag(account)
|
||||
}
|
||||
}
|
||||
#if os(macOS)
|
||||
|
Reference in New Issue
Block a user