refactor: expose state flows via asStateFlow
Drops the explicit getters and an unused import, and lets an emptyList type argument be inferred.
This commit is contained in:
@@ -27,9 +27,9 @@ import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.Semaphore
|
||||
@@ -91,12 +91,10 @@ class LocalDictionaryRepository(
|
||||
override val coroutineContext = Job() + ioDispatcher
|
||||
|
||||
private val mutableDictionaries = MutableStateFlow<List<Dictionary>>(emptyList())
|
||||
val dictionaries: StateFlow<List<Dictionary>>
|
||||
get() = mutableDictionaries
|
||||
val dictionaries: StateFlow<List<Dictionary>> = mutableDictionaries.asStateFlow()
|
||||
|
||||
private val mutableIndexingProgress = MutableStateFlow(IndexingProgress())
|
||||
val indexingProgress: StateFlow<IndexingProgress>
|
||||
get() = mutableIndexingProgress
|
||||
val indexingProgress: StateFlow<IndexingProgress> = mutableIndexingProgress.asStateFlow()
|
||||
|
||||
private val indexingMutex = Mutex()
|
||||
private val indexingSemaphore = Semaphore(1)
|
||||
@@ -470,7 +468,7 @@ class LocalDictionaryRepository(
|
||||
if (dictFile.exists() && !dictFile.delete()) {
|
||||
return@withContext Pair(
|
||||
"Failed to delete dictionary file: ${dictFile.absolutePath}",
|
||||
emptyList<String>(),
|
||||
emptyList(),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user