fix(detail): 콘텐츠/시리즈 상세 로딩 실패 시 자동 복귀를 적용한다

This commit is contained in:
Yu Sung
2026-02-26 01:20:37 +09:00
parent db68aa90d2
commit 38fb818f4b
4 changed files with 119 additions and 11 deletions

View File

@@ -17,6 +17,8 @@ struct SeriesDetailView: View {
@State private var isShowFollowNotifyDialog: Bool = false
@State private var creatorId: Int = 0
@State private var didTriggerAutoBackOnLoadFailure: Bool = false
@State private var isViewVisible: Bool = false
var body: some View {
BaseView(isLoading: $viewModel.isLoading) {
@@ -38,11 +40,7 @@ struct SeriesDetailView: View {
.resizable()
.frame(width: 20, height: 20)
.onTapGesture {
if presentationMode.wrappedValue.isPresented {
presentationMode.wrappedValue.dismiss()
} else {
AppState.shared.back()
}
goBack()
}
Spacer()
@@ -243,9 +241,51 @@ struct SeriesDetailView: View {
.navigationBarBackButtonHidden()
}
.onAppear {
isViewVisible = true
didTriggerAutoBackOnLoadFailure = false
viewModel.seriesId = seriesId
viewModel.getSeriesDetail()
}
.onDisappear {
isViewVisible = false
}
.onChange(of: viewModel.isShowPopup) { isShowing in
guard isShowing else { return }
guard viewModel.seriesDetail == nil else { return }
guard !didTriggerAutoBackOnLoadFailure else { return }
didTriggerAutoBackOnLoadFailure = true
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
guard isViewVisible else { return }
goBack()
}
}
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .top, autohideIn: 2) {
GeometryReader { geo in
HStack {
Spacer()
Text(viewModel.errorMessage)
.padding(.vertical, 13.3)
.frame(width: screenSize().width - 66.7, alignment: .center)
.appFont(size: 12, weight: .medium)
.background(Color(hex: "3bb9f1"))
.foregroundColor(Color.white)
.multilineTextAlignment(.center)
.cornerRadius(20)
.padding(.top, 66.7)
Spacer()
}
}
}
}
private func goBack() {
if presentationMode.wrappedValue.isPresented {
presentationMode.wrappedValue.dismiss()
} else {
AppState.shared.back()
}
}
}