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:
2026-09-02 12:55:48 +08:00
parent 5de466792a
commit 44ebe68f75
@@ -27,9 +27,9 @@ import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.ensureActive import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.update import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import kotlinx.coroutines.supervisorScope import kotlinx.coroutines.supervisorScope
import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.Semaphore import kotlinx.coroutines.sync.Semaphore
@@ -95,12 +95,10 @@ class LocalDictionaryRepository(
override val coroutineContext = Job() + ioDispatcher override val coroutineContext = Job() + ioDispatcher
private val mutableDictionaries = MutableStateFlow<List<Dictionary>>(emptyList()) private val mutableDictionaries = MutableStateFlow<List<Dictionary>>(emptyList())
val dictionaries: StateFlow<List<Dictionary>> val dictionaries: StateFlow<List<Dictionary>> = mutableDictionaries.asStateFlow()
get() = mutableDictionaries
private val mutableIndexingProgress = MutableStateFlow(IndexingProgress()) private val mutableIndexingProgress = MutableStateFlow(IndexingProgress())
val indexingProgress: StateFlow<IndexingProgress> val indexingProgress: StateFlow<IndexingProgress> = mutableIndexingProgress.asStateFlow()
get() = mutableIndexingProgress
private val indexingMutex = Mutex() private val indexingMutex = Mutex()
private val indexingSemaphore = Semaphore(1) private val indexingSemaphore = Semaphore(1)
@@ -489,7 +487,7 @@ class LocalDictionaryRepository(
if (dictFile.exists() && !dictFile.delete()) { if (dictFile.exists() && !dictFile.delete()) {
return@withContext Pair( return@withContext Pair(
"Failed to delete dictionary file: ${dictFile.absolutePath}", "Failed to delete dictionary file: ${dictFile.absolutePath}",
emptyList<String>(), emptyList(),
) )
} }