mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-06-10 01:09:29 +00:00
29 lines
632 B
Swift
29 lines
632 B
Swift
import Network
|
|
import SwiftUI
|
|
|
|
@MainActor
|
|
class EditRelationshipNoteViewModel: ObservableObject {
|
|
public var note: String = ""
|
|
public var relatedAccountId: String?
|
|
public var client: Client?
|
|
|
|
@Published var isSaving: Bool = false
|
|
@Published var saveError: Bool = false
|
|
|
|
init() {}
|
|
|
|
func save() async {
|
|
if relatedAccountId != nil,
|
|
client != nil
|
|
{
|
|
isSaving = true
|
|
do {
|
|
let _ = try await client!.post(endpoint: Accounts.relationshipNote(id: relatedAccountId!, json: RelationshipNoteData(note: note)))
|
|
} catch {
|
|
isSaving = false
|
|
saveError = true
|
|
}
|
|
}
|
|
}
|
|
}
|