mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Restore the WFClient when the WriteFreely model initializes
This commit is contained in:
parent
07d306a196
commit
45b6fb533c
@ -26,6 +26,22 @@ class WriteFreelyModel: ObservableObject {
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.account.restoreState()
|
||||
if self.account.isLoggedIn {
|
||||
guard let serverURL = URL(string: self.account.server) else {
|
||||
print("Server URL not found")
|
||||
return
|
||||
}
|
||||
guard let token = self.fetchTokenFromKeychain(
|
||||
username: self.account.username,
|
||||
server: self.account.server
|
||||
) else {
|
||||
print("Could not fetch token from Keychain")
|
||||
return
|
||||
}
|
||||
self.account.login(WFUser(token: token, username: self.account.username))
|
||||
self.client = WFClient(for: serverURL)
|
||||
self.client?.user = self.account.user
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user