Skip to content

Commit

Permalink
feat: 자기소개 작성 안한 사용자 도착한 보틀 볼 수 있도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
leemhyungyu committed Nov 7, 2024
1 parent 84412a6 commit f8afb27
Showing 1 changed file with 24 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,43 +100,36 @@ extension SandBeachFeature {

return .run { send in
async let _ = authClient.checkUpdateVersion()
async let isExsit = try await profileClient.checkExistIntroduction()
// 자기소개 없는 상태
if try await !isExsit {
let userProfileStatus = try await profileClient.fetchUserProfileSelect()
let userBottleInfo = try await bottleClient.fetchUserBottleInfo()
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 {
await send(.userStateFetchCompleted(
userState: .noIntroduction,
isDisableButton: true))
userState: .hasNewBottle(bottleCount: newBottlesCount),
isDisableButton: false))
return
}

let userBottleInfo = try await bottleClient.fetchUserBottleInfo()
let newBottlesCount = userBottleInfo.randomBottleCount
// 새로 도착한 보틀이 있는 상태
if activeBottlesCount > 0 {
await send(.userStateFetchCompleted(
userState: .hasActiveBottle(bottleCount: activeBottlesCount),
isDisableButton: false))
return
}

if newBottlesCount > 0 {
if userProfileStatus == .empty || userProfileStatus == .doneIntroduction {
await send(.userStateFetchCompleted(
userState: .hasNewBottle(bottleCount: newBottlesCount),
isDisableButton: false)
)
} else {
let bottlesStorageList = try await bottleClient.fetchBottleStorageList()
let activeBottlesCount = bottlesStorageList.pingPongBottles
.filter { $0.lastStatus != .conversationStopped && $0.lastStatus != .contactSharedByMeOnly }.count

// 자기소개만 작성한 상태
if activeBottlesCount <= 0 {
// TODO: time 설정
let nextBottleLeftHours = userBottleInfo.nextBottlLeftHours
await send(.userStateFetchCompleted(
userState: .noBottle(time: nextBottleLeftHours ?? 0),
isDisableButton: false)
)
} else { // 대화 중인 보틀이 있는 상태
await send(.userStateFetchCompleted(
userState: .hasActiveBottle(bottleCount: activeBottlesCount),
isDisableButton: false)
)
}
userState: .noIntroduction,
isDisableButton: true))
} else if userProfileStatus == .doneProfileImage {
await send(.userStateFetchCompleted(
userState: .noBottle(time: nextBottleLeftHours ?? 0),
isDisableButton: false))
}
} catch: { error, send in
// TODO: 에러 핸들링
Expand Down

0 comments on commit f8afb27

Please sign in to comment.