Skip to content

Commit 1ff0652

Browse files
authored
fix: Sync local patient after updated (#145)
1 parent fa9a608 commit 1ff0652

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

OCKSample/Main/Profile/ProfileViewModel.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ class ProfileViewModel: ObservableObject {
6969
}
7070

7171
if patientHasBeenUpdated {
72-
_ = try await AppDelegateKey.defaultValue?.store.updatePatient(patientToUpdate)
73-
Logger.profile.info("Successfully updated patient")
72+
if let anyPatient = try await AppDelegateKey.defaultValue?.store.updateAnyPatient(patientToUpdate),
73+
let updatedPatient = anyPatient as? OCKPatient {
74+
self.patient = updatedPatient
75+
Logger.profile.info("Successfully updated patient and synced local state.")
76+
} else {
77+
Logger.profile.error("Patient was updated in store but could not be cast to OCKPatient.")
78+
}
7479
}
7580
}
7681
}

0 commit comments

Comments
 (0)