Skip to content

Commit

Permalink
fix: delete methods not resolving #161 (#177)
Browse files Browse the repository at this point in the history
* fix: delete methods not resolving #161

* fix: add resolve for delete records by time range

* refactor: remove useless if condition
  • Loading branch information
matinzd authored Nov 23, 2024
1 parent b0c34c4 commit cb23091
Show file tree
Hide file tree
Showing 2 changed files with 10,986 additions and 7,625 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,16 @@ class HealthConnectManager(private val applicationContext: ReactApplicationConte
coroutineScope.launch {
val record = reactRecordTypeToClassMap[recordType]
if (record != null) {
healthConnectClient.deleteRecords(
recordType = record,
recordIdsList = recordIdsList.toArrayList().mapNotNull { it.toString() }.toList(),
clientRecordIdsList = if (clientRecordIdsList.size() > 0) clientRecordIdsList.toArrayList()
.mapNotNull { it.toString() }.toList() else emptyList()
)
try {
healthConnectClient.deleteRecords(
recordType = record,
recordIdsList = recordIdsList.toArrayList().mapNotNull { it.toString() }.toList(),
clientRecordIdsList = clientRecordIdsList.toArrayList().mapNotNull { it.toString() }.toList()
)
promise.resolve(true)
} catch (e: Exception) {
promise.rejectWithException(e)
}
}
}
}
Expand All @@ -273,9 +277,14 @@ class HealthConnectManager(private val applicationContext: ReactApplicationConte
coroutineScope.launch {
val record = reactRecordTypeToClassMap[recordType]
if (record != null) {
healthConnectClient.deleteRecords(
recordType = record, timeRangeFilter = timeRangeFilter.getTimeRangeFilter()
)
try {
healthConnectClient.deleteRecords(
recordType = record, timeRangeFilter = timeRangeFilter.getTimeRangeFilter()
)
promise.resolve(true)
} catch (e: Exception) {
promise.rejectWithException(e)
}
}
}
}
Expand Down
Loading

0 comments on commit cb23091

Please sign in to comment.