Skip to content

Commit

Permalink
Made all functions suspending
Browse files Browse the repository at this point in the history
Signed-off-by: Arnau Mora Gras <[email protected]>
  • Loading branch information
ArnyminerZ committed Apr 10, 2024
1 parent 1467287 commit 8e36066
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions app/src/main/java/at/bitfire/icsdroid/db/dao/SubscriptionsDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import kotlinx.coroutines.flow.Flow
interface SubscriptionsDao {

@Insert
fun add(subscription: Subscription): Long
suspend fun add(subscription: Subscription): Long

@Delete
fun delete(vararg subscriptions: Subscription)
suspend fun delete(vararg subscriptions: Subscription)

@Deprecated(
message = "Replace LiveData by Flows",
Expand All @@ -33,16 +33,16 @@ interface SubscriptionsDao {
fun getAllFlow(): Flow<List<Subscription>>

@Query("SELECT * FROM subscriptions")
fun getAll(): List<Subscription>
suspend fun getAll(): List<Subscription>

@Query("SELECT * FROM subscriptions WHERE id=:id")
fun getById(id: Long): Subscription?
suspend fun getById(id: Long): Subscription?

@Query("SELECT * FROM subscriptions WHERE calendarId=:calendarId")
fun getByCalendarId(calendarId: Long?): Subscription?
suspend fun getByCalendarId(calendarId: Long?): Subscription?

@Query("SELECT * FROM subscriptions WHERE url=:url")
fun getByUrl(url: String): Subscription?
suspend fun getByUrl(url: String): Subscription?

@Deprecated(
message = "Replace LiveData by Flows",
Expand All @@ -65,22 +65,22 @@ interface SubscriptionsDao {
fun getErrorMessageFlow(id: Long): Flow<String?>

@Update
fun update(subscription: Subscription)
suspend fun update(subscription: Subscription)

@Query("UPDATE subscriptions SET calendarId=:calendarId WHERE id=:id")
fun updateCalendarId(id: Long, calendarId: Long?)
suspend fun updateCalendarId(id: Long, calendarId: Long?)

@Query("UPDATE subscriptions SET lastSync=:lastSync, errorMessage=null WHERE id=:id")
fun updateStatusNotModified(id: Long, lastSync: Long = System.currentTimeMillis())
suspend fun updateStatusNotModified(id: Long, lastSync: Long = System.currentTimeMillis())

@Query("UPDATE subscriptions SET eTag=:eTag, lastModified=:lastModified, lastSync=:lastSync, errorMessage=null WHERE id=:id")
fun updateStatusSuccess(id: Long, eTag: String?, lastModified: Long?, lastSync: Long = System.currentTimeMillis())
suspend fun updateStatusSuccess(id: Long, eTag: String?, lastModified: Long?, lastSync: Long = System.currentTimeMillis())

@Query("UPDATE subscriptions SET errorMessage=:message WHERE id=:id")
fun updateStatusError(id: Long, message: String?)
suspend fun updateStatusError(id: Long, message: String?)

@Query("UPDATE subscriptions SET url=:url WHERE id=:id")
fun updateUrl(id: Long, url: Uri)
suspend fun updateUrl(id: Long, url: Uri)


data class SubscriptionWithCredential(
Expand Down

0 comments on commit 8e36066

Please sign in to comment.