Skip to content

Commit 1cfa01f

Browse files
fix: Change return type of getConversationByGroupID to nullable for epoch changes (#2593)
* Commit with unresolved merge conflicts outside of * empty trigger commit * chore: fix merge conflicts --------- Co-authored-by: Alexandre Ferris <[email protected]>
1 parent 72d393f commit 1cfa01f

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/conversation/ConversationDAO.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ interface ConversationDAO {
106106
suspend fun getConversationsWithoutMetadata(): List<QualifiedIDEntity>
107107
suspend fun clearContent(conversationId: QualifiedIDEntity)
108108
suspend fun updateMlsVerificationStatus(verificationStatus: ConversationEntity.VerificationStatus, conversationId: QualifiedIDEntity)
109-
suspend fun getConversationByGroupID(groupID: String): ConversationViewEntity
109+
suspend fun getConversationByGroupID(groupID: String): ConversationViewEntity?
110110
suspend fun observeUnreadArchivedConversationsCount(): Flow<Long>
111111
suspend fun observeDegradedConversationNotified(conversationId: QualifiedIDEntity): Flow<Boolean>
112112
suspend fun updateDegradedConversationNotifiedFlag(conversationId: QualifiedIDEntity, updateFlag: Boolean)

persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/conversation/ConversationDAOImpl.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ internal class ConversationDAOImpl internal constructor(
247247
.map { it?.let { conversationMapper.toModel(it) } }
248248
}
249249

250-
override suspend fun getConversationByGroupID(groupID: String): ConversationViewEntity {
250+
override suspend fun getConversationByGroupID(groupID: String): ConversationViewEntity? {
251251
return conversationQueries.selectByGroupId(groupID)
252-
.executeAsOne()
253-
.let { it.let { conversationMapper.toModel(it) } }
252+
.executeAsOneOrNull()
253+
?.let { it.let { conversationMapper.toModel(it) } }
254254
}
255255

256256
override suspend fun getConversationIdByGroupID(groupID: String) = withContext(coroutineContext) {

persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/ConversationDAOTest.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,22 @@ class ConversationDAOTest : BaseDatabaseTest() {
18261826
}
18271827
}
18281828

1829+
@Test
1830+
fun givenInsertedConversations_whenGettingConversationByInexistingGroupId_thenReturnNull() = runTest {
1831+
// given
1832+
val expected = null
1833+
conversationDAO.insertConversation(conversationEntity4)
1834+
1835+
// when
1836+
val result = conversationDAO.getConversationByGroupID("call_subconversation_groupid")
1837+
1838+
// then
1839+
assertEquals(
1840+
expected,
1841+
result
1842+
)
1843+
}
1844+
18291845
private fun ConversationEntity.toViewEntity(userEntity: UserEntity? = null): ConversationViewEntity {
18301846
val protocol: ConversationEntity.Protocol
18311847
val mlsGroupId: String?

0 commit comments

Comments
 (0)