Database bug fix (#5902)

* make database function calls suspending and update room version

* replace MainScope with coroutineScope for database operations

* add suspend keyword and refactor code
This commit is contained in:
Rohit Verma 2024-10-27 19:08:40 +05:30 committed by GitHub
parent bc065c8792
commit cdc4f89da5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 28 additions and 34 deletions

View file

@ -37,15 +37,11 @@ public abstract class PlaceDao {
*/
public Completable save(final Place place) {
return Completable
.fromAction(() -> {
saveSynchronous(place);
});
.fromAction(() -> saveSynchronous(place));
}
/**
* Deletes all Place objects from the database.
*
* @return A Completable that completes once the deletion operation is done.
*/
@Query("DELETE FROM place")
public abstract void deleteAllSynchronous();
@ -53,11 +49,9 @@ public abstract class PlaceDao {
/**
* Deletes all Place objects from the database.
*
* @return A Completable that completes once the deletion operation is done.
*/
public Completable deleteAll() {
return Completable
.fromAction(() -> {
deleteAllSynchronous();
});
return Completable.fromAction(this::deleteAllSynchronous);
}
}