From e43cdbc7d47065fdeaec5868eb13897bd5a5e0e1 Mon Sep 17 00:00:00 2001 From: StageGuard Date: Wed, 19 Feb 2025 20:00:31 +0800 Subject: [PATCH] fix --- .../kotlin/domain/session/AniAuthConfigurator.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/shared/app-data/src/commonMain/kotlin/domain/session/AniAuthConfigurator.kt b/app/shared/app-data/src/commonMain/kotlin/domain/session/AniAuthConfigurator.kt index 2245f4e93c..5b3a5e81b2 100644 --- a/app/shared/app-data/src/commonMain/kotlin/domain/session/AniAuthConfigurator.kt +++ b/app/shared/app-data/src/commonMain/kotlin/domain/session/AniAuthConfigurator.kt @@ -24,6 +24,7 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.flatMapConcat @@ -113,16 +114,12 @@ class AniAuthConfigurator( } .collectLatest { authStateNew -> emit(authStateNew) } } - .shareIn( - scope, - SharingStarted.WhileSubscribed(), - ) + .distinctUntilChanged() + .shareIn(scope, SharingStarted.WhileSubscribed(), replay = 1) /** * 启动授权请求检查循环. - * - * - * + * * 会启动两个协程: * * [checkAuthorizeRequestLoop] 用于检查授权请求状态. * * [requireAuthorizeStarterTaskLoop] 用于启动 [SessionManager.requireAuthorize].