Add swipe to remove accounts in Preferences

This commit is contained in:
Shadowfacts 2020-09-16 22:17:20 -04:00
parent 14e8c11f02
commit ee90b20f7f
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 14 additions and 0 deletions

View File

@ -37,7 +37,21 @@ struct PreferencesView: View {
} }
} }
} }
}.onDelete { (indices: IndexSet) in
var indices = indices
var logoutFromCurrent = false
if let index = indices.first(where: { localData.accounts[$0] == localData.getMostRecentAccount() }) {
logoutFromCurrent = true
indices.remove(index)
} }
localData.accounts.remove(atOffsets: indices)
if logoutFromCurrent {
self.logoutPressed()
}
}
Button(action: { Button(action: {
NotificationCenter.default.post(name: .addAccount, object: nil) NotificationCenter.default.post(name: .addAccount, object: nil)
}) { }) {