mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 03:32:38 +08:00
perf: 优化创建文件夹逻辑
This commit is contained in:
parent
b4f5f85a0f
commit
c91fd2c6c5
|
@ -29,6 +29,7 @@ import li.songe.gkd.util.LoadStatus
|
|||
import li.songe.gkd.util.checkUpdate
|
||||
import li.songe.gkd.util.client
|
||||
import li.songe.gkd.util.dbFolder
|
||||
import li.songe.gkd.util.initFolder
|
||||
import li.songe.gkd.util.json
|
||||
import li.songe.gkd.util.launchTry
|
||||
import li.songe.gkd.util.storeFlow
|
||||
|
@ -86,6 +87,12 @@ class HomePageVm @Inject constructor() : ViewModel() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launchTry(Dispatchers.IO) {
|
||||
// 在某些机型由于未知原因创建失败
|
||||
// 在此保证每次重新打开APP都能重新检测创建
|
||||
initFolder()
|
||||
}
|
||||
}
|
||||
|
||||
val uploadStatusFlow = MutableStateFlow<LoadStatus<GithubPoliciesAsset>?>(null)
|
||||
|
@ -105,10 +112,10 @@ class HomePageVm @Inject constructor() : ViewModel() {
|
|||
onUpload { bytesSentTotal, contentLength ->
|
||||
if (uploadStatusFlow.value is LoadStatus.Loading) {
|
||||
uploadStatusFlow.value =
|
||||
LoadStatus.Loading(bytesSentTotal / contentLength.toFloat())
|
||||
LoadStatus.Loading(bytesSentTotal / contentLength.toFloat())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (response.headers["X_RPC_OK"] == "true") {
|
||||
val policiesAsset = response.body<GithubPoliciesAsset>()
|
||||
uploadStatusFlow.value = LoadStatus.Success(policiesAsset)
|
||||
|
|
Loading…
Reference in New Issue
Block a user