From 069181b1b7a0db1fb6b0844fff30a0a8006970a8 Mon Sep 17 00:00:00 2001 From: Pablo Pajuelo Cabezas Date: Tue, 17 Dec 2024 12:23:54 +0100 Subject: [PATCH 1/2] fix: [ANDROAPP-6717] Crash when syncing a TEI from map --- .../java/org/dhis2/utils/granularsync/GranularSyncRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..4c94912304 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() } } From fe3047c2d9d61d371254340c022a76c69d0eff32 Mon Sep 17 00:00:00 2001 From: Xavier Molloy Date: Thu, 19 Dec 2024 08:54:04 +0100 Subject: [PATCH 2/2] 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() }