Skip to content

Commit

Permalink
fix: clearing new clients was being executed on main thread (#2116)
Browse files Browse the repository at this point in the history
  • Loading branch information
gongracr authored Oct 6, 2023
1 parent 9200a35 commit 882fbf9
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.wire.kalium.persistence.dao.client.InsertClientParam
import com.wire.kalium.persistence.util.mapToList
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.withContext
import kotlinx.datetime.Instant
import kotlin.coroutines.CoroutineContext

Expand All @@ -49,12 +50,14 @@ internal class NewClientDAOImpl(
) : NewClientDAO {

override suspend fun insertNewClient(client: InsertClientParam) = with(client) {
newClientsQueries.insertNewClient(
id = id,
device_type = deviceType,
registration_date = registrationDate,
model = model
)
withContext(queriesContext) {
newClientsQueries.insertNewClient(
id = id,
device_type = deviceType,
registration_date = registrationDate,
model = model
)
}
}

override suspend fun observeNewClients(): Flow<List<NewClientEntity>> =
Expand All @@ -63,7 +66,7 @@ internal class NewClientDAOImpl(
.flowOn(queriesContext)
.mapToList()

override suspend fun clearNewClients() {
override suspend fun clearNewClients() = withContext(queriesContext) {
newClientsQueries.clearNewClients()
}
}

0 comments on commit 882fbf9

Please sign in to comment.