From 249ed1c8dc432ee63f6f44de03e3b8785eff91c2 Mon Sep 17 00:00:00 2001 From: Rohit Verma Date: Sat, 26 Oct 2024 23:00:17 +0530 Subject: [PATCH] make database function calls suspending and update room version --- .../database/NotForUploadStatusDao.kt | 10 +++++----- .../customselector/database/UploadedStatusDao.kt | 14 +++++++------- gradle.properties | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/customselector/database/NotForUploadStatusDao.kt b/app/src/main/java/fr/free/nrw/commons/customselector/database/NotForUploadStatusDao.kt index 872388f40..b75a6e1d4 100644 --- a/app/src/main/java/fr/free/nrw/commons/customselector/database/NotForUploadStatusDao.kt +++ b/app/src/main/java/fr/free/nrw/commons/customselector/database/NotForUploadStatusDao.kt @@ -15,19 +15,19 @@ abstract class NotForUploadStatusDao { * Insert into Not For Upload status. */ @Insert(onConflict = OnConflictStrategy.REPLACE) - abstract fun insert(notForUploadStatus: NotForUploadStatus) + abstract suspend fun insert(notForUploadStatus: NotForUploadStatus) /** * Delete Not For Upload status entry. */ @Delete - abstract fun delete(notForUploadStatus: NotForUploadStatus) + abstract suspend fun delete(notForUploadStatus: NotForUploadStatus) /** * Query Not For Upload status with image sha1. */ @Query("SELECT * FROM images_not_for_upload_table WHERE imageSHA1 = (:imageSHA1) ") - abstract fun getFromImageSHA1(imageSHA1: String): NotForUploadStatus? + abstract suspend fun getFromImageSHA1(imageSHA1: String): NotForUploadStatus? /** * Asynchronous image sha1 query. @@ -38,7 +38,7 @@ abstract class NotForUploadStatusDao { * Deletion Not For Upload status with image sha1. */ @Query("DELETE FROM images_not_for_upload_table WHERE imageSHA1 = (:imageSHA1) ") - abstract fun deleteWithImageSHA1(imageSHA1: String) + abstract suspend fun deleteWithImageSHA1(imageSHA1: String) /** * Asynchronous image sha1 deletion. @@ -49,5 +49,5 @@ abstract class NotForUploadStatusDao { * Check whether the imageSHA1 is present in database */ @Query("SELECT COUNT() FROM images_not_for_upload_table WHERE imageSHA1 = (:imageSHA1) ") - abstract fun find(imageSHA1: String): Int + abstract suspend fun find(imageSHA1: String): Int } diff --git a/app/src/main/java/fr/free/nrw/commons/customselector/database/UploadedStatusDao.kt b/app/src/main/java/fr/free/nrw/commons/customselector/database/UploadedStatusDao.kt index 03cbb176f..378af5b8d 100644 --- a/app/src/main/java/fr/free/nrw/commons/customselector/database/UploadedStatusDao.kt +++ b/app/src/main/java/fr/free/nrw/commons/customselector/database/UploadedStatusDao.kt @@ -17,31 +17,31 @@ abstract class UploadedStatusDao { * Insert into uploaded status. */ @Insert(onConflict = OnConflictStrategy.REPLACE) - abstract fun insert(uploadedStatus: UploadedStatus) + abstract suspend fun insert(uploadedStatus: UploadedStatus) /** * Update uploaded status entry. */ @Update - abstract fun update(uploadedStatus: UploadedStatus) + abstract suspend fun update(uploadedStatus: UploadedStatus) /** * Delete uploaded status entry. */ @Delete - abstract fun delete(uploadedStatus: UploadedStatus) + abstract suspend fun delete(uploadedStatus: UploadedStatus) /** * Query uploaded status with image sha1. */ @Query("SELECT * FROM uploaded_table WHERE imageSHA1 = (:imageSHA1) ") - abstract fun getFromImageSHA1(imageSHA1: String): UploadedStatus? + abstract suspend fun getFromImageSHA1(imageSHA1: String): UploadedStatus? /** * Query uploaded status with modified image sha1. */ @Query("SELECT * FROM uploaded_table WHERE modifiedImageSHA1 = (:modifiedImageSHA1) ") - abstract fun getFromModifiedImageSHA1(modifiedImageSHA1: String): UploadedStatus? + abstract suspend fun getFromModifiedImageSHA1(modifiedImageSHA1: String): UploadedStatus? /** * Asynchronous insert into uploaded status table. @@ -55,7 +55,7 @@ abstract class UploadedStatusDao { * Check whether the imageSHA1 is present in database */ @Query("SELECT COUNT() FROM uploaded_table WHERE imageSHA1 = (:imageSHA1) AND imageResult = (:imageResult) ") - abstract fun findByImageSHA1( + abstract suspend fun findByImageSHA1( imageSHA1: String, imageResult: Boolean, ): Int @@ -66,7 +66,7 @@ abstract class UploadedStatusDao { @Query( "SELECT COUNT() FROM uploaded_table WHERE modifiedImageSHA1 = (:modifiedImageSHA1) AND modifiedImageResult = (:modifiedImageResult) ", ) - abstract fun findByModifiedImageSHA1( + abstract suspend fun findByModifiedImageSHA1( modifiedImageSHA1: String, modifiedImageResult: Boolean, ): Int diff --git a/gradle.properties b/gradle.properties index 9ca154b75..0aee97f4e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,7 +20,7 @@ android.enableR8.fullMode=false KOTLIN_VERSION=1.9.22 LEAK_CANARY_VERSION=2.10 DAGGER_VERSION=2.23 -ROOM_VERSION=2.5.0 +ROOM_VERSION=2.6.1 PREFERENCE_VERSION=1.1.0 CORE_KTX_VERSION=1.9.0 ADAPTER_DELEGATES_VERSION=4.3.0