File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
commonMain/kotlin/com/wire/kalium/persistence/dao/conversation
commonTest/kotlin/com/wire/kalium/persistence/dao Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ interface ConversationDAO {
106
106
suspend fun getConversationsWithoutMetadata (): List <QualifiedIDEntity >
107
107
suspend fun clearContent (conversationId : QualifiedIDEntity )
108
108
suspend fun updateMlsVerificationStatus (verificationStatus : ConversationEntity .VerificationStatus , conversationId : QualifiedIDEntity )
109
- suspend fun getConversationByGroupID (groupID : String ): ConversationViewEntity
109
+ suspend fun getConversationByGroupID (groupID : String ): ConversationViewEntity ?
110
110
suspend fun observeUnreadArchivedConversationsCount (): Flow <Long >
111
111
suspend fun observeDegradedConversationNotified (conversationId : QualifiedIDEntity ): Flow <Boolean >
112
112
suspend fun updateDegradedConversationNotifiedFlag (conversationId : QualifiedIDEntity , updateFlag : Boolean )
Original file line number Diff line number Diff line change @@ -247,10 +247,10 @@ internal class ConversationDAOImpl internal constructor(
247
247
.map { it?.let { conversationMapper.toModel(it) } }
248
248
}
249
249
250
- override suspend fun getConversationByGroupID (groupID : String ): ConversationViewEntity {
250
+ override suspend fun getConversationByGroupID (groupID : String ): ConversationViewEntity ? {
251
251
return conversationQueries.selectByGroupId(groupID)
252
- .executeAsOne ()
253
- .let { it.let { conversationMapper.toModel(it) } }
252
+ .executeAsOneOrNull ()
253
+ ? .let { it.let { conversationMapper.toModel(it) } }
254
254
}
255
255
256
256
override suspend fun getConversationIdByGroupID (groupID : String ) = withContext(coroutineContext) {
Original file line number Diff line number Diff line change @@ -1826,6 +1826,22 @@ class ConversationDAOTest : BaseDatabaseTest() {
1826
1826
}
1827
1827
}
1828
1828
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
+
1829
1845
private fun ConversationEntity.toViewEntity (userEntity : UserEntity ? = null): ConversationViewEntity {
1830
1846
val protocol: ConversationEntity .Protocol
1831
1847
val mlsGroupId: String?
You can’t perform that action at this time.
0 commit comments