Use operator invoke.
This commit is contained in:
parent
48d78111db
commit
5b4069d9f4
5 changed files with 8 additions and 8 deletions
|
|
@ -127,13 +127,13 @@ class DeveloperSettingsPresenter @Inject constructor(
|
|||
|
||||
private fun CoroutineScope.computeCacheSize(cacheSize: MutableState<Async<String>>) = launch {
|
||||
suspend {
|
||||
computeCacheSizeUseCase.execute()
|
||||
computeCacheSizeUseCase()
|
||||
}.execute(cacheSize)
|
||||
}
|
||||
|
||||
private fun CoroutineScope.clearCache(clearCacheAction: MutableState<Async<Unit>>) = launch {
|
||||
suspend {
|
||||
clearCacheUseCase.execute()
|
||||
clearCacheUseCase()
|
||||
}.execute(clearCacheAction)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import javax.inject.Inject
|
|||
import javax.inject.Provider
|
||||
|
||||
interface ClearCacheUseCase {
|
||||
suspend fun execute()
|
||||
suspend operator fun invoke()
|
||||
}
|
||||
|
||||
@ContributesBinding(SessionScope::class)
|
||||
|
|
@ -44,7 +44,7 @@ class DefaultClearCacheUseCase @Inject constructor(
|
|||
private val authenticationService: MatrixAuthenticationService,
|
||||
private val okHttpClient: Provider<OkHttpClient>,
|
||||
) : ClearCacheUseCase {
|
||||
override suspend fun execute() = withContext(coroutineDispatchers.io) {
|
||||
override suspend fun invoke() = withContext(coroutineDispatchers.io) {
|
||||
// Clear Matrix cache
|
||||
matrixClient.clearCache()
|
||||
// Clear Coil cache
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import kotlinx.coroutines.withContext
|
|||
import javax.inject.Inject
|
||||
|
||||
interface ComputeCacheSizeUseCase {
|
||||
suspend fun execute(): String
|
||||
suspend operator fun invoke(): String
|
||||
}
|
||||
|
||||
@ContributesBinding(SessionScope::class)
|
||||
|
|
@ -38,7 +38,7 @@ class DefaultComputeCacheSizeUseCase @Inject constructor(
|
|||
private val coroutineDispatchers: CoroutineDispatchers,
|
||||
private val fileSizeFormatter: FileSizeFormatter,
|
||||
) : ComputeCacheSizeUseCase {
|
||||
override suspend fun execute(): String = withContext(coroutineDispatchers.io) {
|
||||
override suspend fun invoke(): String = withContext(coroutineDispatchers.io) {
|
||||
var cumulativeSize = 0L
|
||||
cumulativeSize += matrixClient.getCacheSize()
|
||||
// - 4096 to not include the size fo the folder
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class FakeClearCacheUseCase : ClearCacheUseCase {
|
|||
var executeHasBeenCalled = false
|
||||
private set
|
||||
|
||||
override suspend fun execute() = simulateLongTask {
|
||||
override suspend fun invoke() = simulateLongTask {
|
||||
executeHasBeenCalled = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package io.element.android.features.preferences.impl.tasks
|
|||
import io.element.android.tests.testutils.simulateLongTask
|
||||
|
||||
class FakeComputeCacheSizeUseCase : ComputeCacheSizeUseCase {
|
||||
override suspend fun execute() = simulateLongTask {
|
||||
override suspend fun invoke() = simulateLongTask {
|
||||
"O kB"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue