Fixed the "logUserOut()" function in the ProfileView view for the Profile module to actually remove the account from the keychain storage.

This commit is contained in:
Javier Cicchelli 2022-12-20 03:33:03 +01:00
parent d8efab9c31
commit e9a7e8b33b

View File

@ -7,6 +7,7 @@
// //
import DataModels import DataModels
import KeychainStorage
import SwiftUI import SwiftUI
public struct ProfileView: View { public struct ProfileView: View {
@ -15,6 +16,10 @@ public struct ProfileView: View {
@Environment(\.dismiss) private var dismiss @Environment(\.dismiss) private var dismiss
// MARK: Storages
@KeychainStorage(key: .KeychainStorage.account) var account: Account?
// MARK: Properties // MARK: Properties
private let user: User? private let user: User?
@ -84,7 +89,7 @@ public struct ProfileView: View {
Section { Section {
Button { Button {
logout() Task { await logUserOut() }
} label: { } label: {
Text( Text(
"profile.button.log_out.text", "profile.button.log_out.text",
@ -107,6 +112,16 @@ public struct ProfileView: View {
} }
// MARK: - Helpers
private extension ProfileView {
func logUserOut() async {
account = nil
logout()
}
}
// MARK: - Images+Constants // MARK: - Images+Constants
private extension Image { private extension Image {