Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public final class io/getstream/chat/android/offline/repository/domain/message/i
public final class io/getstream/chat/android/offline/repository/domain/message/internal/MessageDao_Impl : io/getstream/chat/android/offline/repository/domain/message/internal/MessageDao {
public fun <init> (Landroidx/room/RoomDatabase;)V
public fun deleteAll (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun deleteAllDrafts (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun deleteAttachments (Ljava/util/List;)V
public fun deleteAttachmentsChunked (Ljava/util/List;)V
public fun deleteChannelMessagesBefore (Ljava/lang/String;Ljava/util/Date;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ internal class DatabaseMessageRepository(
replyMessageCache.evictAll()
dbMutex.withLock {
messageDao.deleteAll()
messageDao.deleteAllDrafts()
replyMessageDao.deleteAll()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ internal interface MessageDao {
@Query("DELETE FROM $MESSAGE_ENTITY_TABLE_NAME")
suspend fun deleteAll()

@Query("DELETE FROM $DRAFT_MESSAGE_ENTITY_TABLE_NAME")
suspend fun deleteAllDrafts()

private companion object {
private const val SQLITE_MAX_VARIABLE_NUMBER: Int = 999
private const val NO_LIMIT: Int = -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,26 @@ internal class MessageRepositoryTests {
// then
verify(messageDao).deleteMessages(messageIds)
}

@Test
fun `when calling clear, then all related tables are cleared`() = runTest(testDispatcher) {
// given
val repository = DatabaseMessageRepository(
this,
messageDao,
replyMessageDao,
pollDao,
::randomUser,
randomUser(id = "currentUserId"),
emptySet(),
)

// when
repository.clear()

// then
verify(messageDao).deleteAll()
verify(messageDao).deleteAllDrafts()
verify(replyMessageDao).deleteAll()
}
}
Loading