diff --git a/Projects/Feature/SandBeach/Interface/Sources/SandBeach/SandBeachFeatureInterface.swift b/Projects/Feature/SandBeach/Interface/Sources/SandBeach/SandBeachFeatureInterface.swift index f7f4e9a4..e9e8f338 100644 --- a/Projects/Feature/SandBeach/Interface/Sources/SandBeach/SandBeachFeatureInterface.swift +++ b/Projects/Feature/SandBeach/Interface/Sources/SandBeach/SandBeachFeatureInterface.swift @@ -97,39 +97,51 @@ extension SandBeachFeature { Log.error(error) } }) - + return .run { send in - async let _ = authClient.checkUpdateVersion() - let userProfileStatus = try await profileClient.fetchUserProfileSelect() - let userBottleInfo = try await bottleClient.fetchUserBottleInfo() + async let versionCheckTask: Void = authClient.checkUpdateVersion() + async let userProfileStatusTask = profileClient.fetchUserProfileSelect() + async let userBottleInfoTask = bottleClient.fetchUserBottleInfo() + async let bottlesStorageListTask = bottleClient.fetchBottleStorageList() + + let (_, userProfileStatus, userBottleInfo, bottlesStorageList) = try await ( + versionCheckTask, + userProfileStatusTask, + userBottleInfoTask, + bottlesStorageListTask + ) + let newBottlesCount = userBottleInfo.randomBottleCount - let bottlesStorageList = try await bottleClient.fetchBottleStorageList() let activeBottlesCount = bottlesStorageList.pingPongBottles .filter { $0.lastStatus != .conversationStopped && $0.lastStatus != .contactSharedByMeOnly }.count let nextBottleLeftHours = userBottleInfo.nextBottlLeftHours - - if newBottlesCount > 0 { + + if userProfileStatus == .empty || userProfileStatus == .doneIntroduction { await send(.userStateFetchCompleted( - userState: .hasNewBottle(bottleCount: newBottlesCount), - isDisableButton: false)) + userState: .noIntroduction, + isDisableButton: true)) return } - if activeBottlesCount > 0 { + if userProfileStatus == .doneProfileImage { await send(.userStateFetchCompleted( - userState: .hasActiveBottle(bottleCount: activeBottlesCount), + userState: .noBottle(time: nextBottleLeftHours ?? 0), isDisableButton: false)) return } - if userProfileStatus == .empty || userProfileStatus == .doneIntroduction { + if newBottlesCount > 0 { await send(.userStateFetchCompleted( - userState: .noIntroduction, - isDisableButton: true)) - } else if userProfileStatus == .doneProfileImage { + userState: .hasNewBottle(bottleCount: newBottlesCount), + isDisableButton: false)) + return + } + + if activeBottlesCount > 0 { await send(.userStateFetchCompleted( - userState: .noBottle(time: nextBottleLeftHours ?? 0), + userState: .hasActiveBottle(bottleCount: activeBottlesCount), isDisableButton: false)) + return } } catch: { error, send in // TODO: 에러 핸들링