mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-04-28 18:58:47 +00:00
29 lines
594 B
Swift
29 lines
594 B
Swift
import Models
|
|
import Network
|
|
import SwiftUI
|
|
|
|
@MainActor
|
|
public class AppAccountViewModel: ObservableObject {
|
|
let appAccount: AppAccount
|
|
let client: Client
|
|
|
|
@Published var account: Account?
|
|
|
|
var acct: String {
|
|
"@\(account?.acct ?? "...")@\(appAccount.server)"
|
|
}
|
|
|
|
public init(appAccount: AppAccount) {
|
|
self.appAccount = appAccount
|
|
client = .init(server: appAccount.server, oauthToken: appAccount.oauthToken)
|
|
}
|
|
|
|
func fetchAccount() async {
|
|
do {
|
|
account = try await client.get(endpoint: Accounts.verifyCredentials)
|
|
} catch {
|
|
print(error)
|
|
}
|
|
}
|
|
}
|