diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt index c601bb59a7..08280dd3ba 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt @@ -241,7 +241,7 @@ class SearchTEMap : FragmentGlobalAbstract() { ), actionButton = { SyncButtonProvider(state = item.state) { - presenter.onSyncIconClick(item.uid) + presenter.onSyncIconClick(item.relatedInfo?.enrollment?.uid) } }, onCardClick = { diff --git a/app/src/main/java/org/dhis2/utils/granularsync/GranularSyncRepository.kt b/app/src/main/java/org/dhis2/utils/granularsync/GranularSyncRepository.kt index 61ae035dd1..3fba0c8dee 100644 --- a/app/src/main/java/org/dhis2/utils/granularsync/GranularSyncRepository.kt +++ b/app/src/main/java/org/dhis2/utils/granularsync/GranularSyncRepository.kt @@ -82,7 +82,7 @@ class GranularSyncRepository( ConflictType.TEI -> { val enrollment = d2.enrollment(syncContext.recordUid()) - d2.observeTei(enrollment?.trackedEntityInstance()!!) + d2.observeTei(enrollment?.trackedEntityInstance() ?: syncContext.recordUid()) .map { it.aggregatedSyncState() } } @@ -121,7 +121,7 @@ class GranularSyncRepository( ConflictType.TEI -> { val enrollment = d2.enrollment(syncContext.recordUid()) - d2.observeTei(enrollment?.trackedEntityInstance()!!) + d2.observeTei(enrollment?.trackedEntityInstance() ?: syncContext.recordUid()) .map { SyncDate(it.lastUpdated()) } } @@ -966,7 +966,7 @@ class GranularSyncRepository( d2.enrollmentModule().enrollments().uid(syncContext.recordUid()).blockingGet() d2.trackedEntityModule().trackedEntityTypes().uid( d2.trackedEntityModule().trackedEntityInstances() - .uid(enrollment?.trackedEntityInstance()!!) + .uid(enrollment?.trackedEntityInstance() ?: syncContext.recordUid()) .blockingGet()?.trackedEntityType(), ) .get().map { it.displayName() }