IceCubesApp/Packages/Account/Sources/Account/Edit/EditRelationshipNoteViewModel.swift
Thomas Ricouard 4189a59cf6
iOS 17+ only support + migrating to Observation framework (#1571)
* Initial iOS 17 + Observable migration

* More Observation

* More observation

* Checkpoint

* Checkpoint

* Bump version to 1.8.0

* SwiftFormat

* Fix home timeline switch on login

* Fix sidebar routerPath

* Fixes on detail view

* Remove print changes

* Simply detail view

* More opt

* Migrate DisplaySettingsLocalValues

* Better post detail transition

* Status detail animation finally right

* Cleanup
2023-09-18 07:01:23 +02:00

30 lines
619 B
Swift

import Network
import Observation
import SwiftUI
@MainActor
@Observable class EditRelationshipNoteViewModel {
public var note: String = ""
public var relatedAccountId: String?
public var client: Client?
var isSaving: Bool = false
var saveError: Bool = false
init() {}
func save() async {
if relatedAccountId != nil,
client != nil
{
isSaving = true
do {
_ = try await client!.post(endpoint: Accounts.relationshipNote(id: relatedAccountId!, json: RelationshipNoteData(note: note)))
} catch {
isSaving = false
saveError = true
}
}
}
}