From fe3047c2d9d61d371254340c022a76c69d0eff32 Mon Sep 17 00:00:00 2001 From: Xavier Molloy Date: Thu, 19 Dec 2024 08:54:04 +0100 Subject: [PATCH] fix: [ANDROAPP-6717] remove non null assertion and use enrollment id when syncing a TEI from map --- .../dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt | 2 +- .../org/dhis2/utils/granularsync/GranularSyncRepository.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 4c94912304..3fba0c8dee 100644 --- a/app/src/main/java/org/dhis2/utils/granularsync/GranularSyncRepository.kt +++ b/app/src/main/java/org/dhis2/utils/granularsync/GranularSyncRepository.kt @@ -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() }