From b2986214b01da987af4d38f2cb6ca9d02e9e2e45 Mon Sep 17 00:00:00 2001 From: JongHoon Date: Sat, 9 Nov 2024 13:04:57 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=AA=A8=EB=9E=98=EC=82=AC=EC=9E=A5=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EC=9E=90=EA=B8=B0=EC=86=8C=EA=B0=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20=EB=B0=8F=20=EB=B3=B4=ED=8B=80=20=EB=B3=B4?= =?UTF-8?q?=EC=97=AC=EC=A3=BC=EA=B8=B0=20=EB=A1=9C=EC=A7=81=20=EC=9B=90?= =?UTF-8?q?=EB=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SandBeach/SandBeachFeatureInterface.swift | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) 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: 에러 핸들링