修复退出登录闪退

This commit is contained in:
tabidachinokaze
2023-08-27 22:02:56 +08:00
parent 1ffec25c68
commit d5a9257534
3 changed files with 4 additions and 5 deletions

View File

@@ -22,6 +22,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.update
@@ -87,7 +88,7 @@ class ElectroViewModel @Inject constructor(
viewModelScope.launch {
application.dataStore.data.map {
it[PreferenceConstant.Key.THEME]
}.filterNotNull().collect {
}.filterNotNull().filter { it.isNotBlank() }.collect {
theme = Theme.valueOf(it)
}
}

View File

@@ -1,6 +1,5 @@
package cn.tabidachi.electro.data.database.dao
import androidx.paging.PagingSource
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
@@ -31,6 +30,4 @@ interface MessageDao {
fun delete(mid: Long)
@Query("select * from message where sid = :sid ORDER BY createTime DESC LIMIT :size")
fun messages(sid: Long, size: Int): List<Message>
@Query("select * from message where sid = :sid ORDER BY createTime DESC")
fun messagePagingSource(sid: Long): PagingSource<Int, Message>
}

View File

@@ -33,6 +33,7 @@ import io.minio.http.Method
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.update
@@ -65,7 +66,7 @@ class SettingsViewModel @Inject constructor(
viewModelScope.launch {
application.dataStore.data.map {
it[PreferenceConstant.Key.THEME]
}.filterNotNull().collect {
}.filterNotNull().filter { it.isNotBlank() }.collect {
theme = Theme.valueOf(it)
}
}