diff --git a/app/src/main/java/org/openedx/app/room/DatabaseManager.kt b/app/src/main/java/org/openedx/app/room/DatabaseManager.kt index f373e0e42..b4b0e5bc9 100644 --- a/app/src/main/java/org/openedx/app/room/DatabaseManager.kt +++ b/app/src/main/java/org/openedx/app/room/DatabaseManager.kt @@ -19,7 +19,7 @@ class DatabaseManager( CoroutineScope(Dispatchers.Main).launch { courseDao.clearCachedData() dashboardDao.clearCachedData() - downloadDao.clearCachedData() + downloadDao.clearOfflineProgress() discoveryDao.clearCachedData() } } diff --git a/core/src/main/java/org/openedx/core/module/db/CalendarDao.kt b/core/src/main/java/org/openedx/core/module/db/CalendarDao.kt index 0dcef5006..686009b92 100644 --- a/core/src/main/java/org/openedx/core/module/db/CalendarDao.kt +++ b/core/src/main/java/org/openedx/core/module/db/CalendarDao.kt @@ -4,6 +4,7 @@ import androidx.room.Dao import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query +import androidx.room.Transaction import org.openedx.core.data.model.room.CourseCalendarEventEntity import org.openedx.core.data.model.room.CourseCalendarStateEntity @@ -55,4 +56,10 @@ interface CalendarDao { checksum: Int? = null, isCourseSyncEnabled: Boolean? = null ) + + @Transaction + suspend fun clearCachedData() { + clearCourseCalendarStateCachedData() + clearCourseCalendarEventsCachedData() + } } diff --git a/core/src/main/java/org/openedx/core/module/db/DownloadDao.kt b/core/src/main/java/org/openedx/core/module/db/DownloadDao.kt index 95ee8c958..a07329e4d 100644 --- a/core/src/main/java/org/openedx/core/module/db/DownloadDao.kt +++ b/core/src/main/java/org/openedx/core/module/db/DownloadDao.kt @@ -32,9 +32,6 @@ interface DownloadDao { @Query("DELETE FROM download_model WHERE id in (:ids)") suspend fun removeAllDownloadModels(ids: List) - @Query("DELETE FROM download_model") - suspend fun clearCachedData() - @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun insertOfflineXBlockProgress(offlineXBlockProgress: OfflineXBlockProgress) @@ -46,4 +43,7 @@ interface DownloadDao { @Query("DELETE FROM offline_x_block_progress_table WHERE id in (:ids)") suspend fun removeOfflineXBlockProgress(ids: List) + + @Query("DELETE FROM offline_x_block_progress_table") + suspend fun clearOfflineProgress() } diff --git a/core/src/main/java/org/openedx/core/repository/CalendarRepository.kt b/core/src/main/java/org/openedx/core/repository/CalendarRepository.kt index e46922605..726709d8a 100644 --- a/core/src/main/java/org/openedx/core/repository/CalendarRepository.kt +++ b/core/src/main/java/org/openedx/core/repository/CalendarRepository.kt @@ -1,9 +1,5 @@ package org.openedx.core.repository -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.async -import kotlinx.coroutines.launch import org.openedx.core.data.api.CourseApi import org.openedx.core.data.model.room.CourseCalendarEventEntity import org.openedx.core.data.model.room.CourseCalendarStateEntity @@ -55,12 +51,7 @@ class CalendarRepository( } suspend fun clearCalendarCachedData() { - CoroutineScope(Dispatchers.Main).launch { - val clearCourseCalendarStateDeferred = async { calendarDao.clearCourseCalendarStateCachedData() } - val clearCourseCalendarEventsDeferred = async { calendarDao.clearCourseCalendarEventsCachedData() } - clearCourseCalendarStateDeferred.await() - clearCourseCalendarEventsDeferred.await() - } + calendarDao.clearCachedData() } suspend fun updateCourseCalendarStateByIdInCache(