Skip to content

Commit

Permalink
feat: 모래사장 화면 자기소개 작성 및 보틀 보여주기 로직 원복 (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
JongHoooon authored Nov 9, 2024
1 parent 032b7d9 commit 7c03dca
Showing 1 changed file with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: 에러 핸들링
Expand Down

0 comments on commit 7c03dca

Please sign in to comment.