From d0c3017b67bacc39f6c8f8800c306e53a5f7920d Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Sat, 18 Feb 2023 14:13:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9C=AA=E8=81=94=E7=BD=91=E6=89=93?= =?UTF-8?q?=E5=BC=80=20App=20=E9=97=AA=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../huanchengfly/tieba/post/utils/ClientUtils.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/huanchengfly/tieba/post/utils/ClientUtils.kt b/app/src/main/java/com/huanchengfly/tieba/post/utils/ClientUtils.kt index df5ea9f9..c27b0170 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/utils/ClientUtils.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/utils/ClientUtils.kt @@ -7,6 +7,7 @@ import com.huanchengfly.tieba.post.api.TiebaApi import com.huanchengfly.tieba.post.dataStore import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch @@ -42,10 +43,13 @@ object ClientUtils { } private suspend fun sync(context: Context) { - TiebaApi.getInstance().syncFlow(clientId).collect { - clientId = it.client.clientId - sampleId = it.wlConfig.sampleId - save(context, it.client.clientId, it.wlConfig.sampleId) - } + TiebaApi.getInstance() + .syncFlow(clientId) + .catch { it.printStackTrace() } + .collect { + clientId = it.client.clientId + sampleId = it.wlConfig.sampleId + save(context, it.client.clientId, it.wlConfig.sampleId) + } } } \ No newline at end of file