From 0a27d3158b19231c6db3494602cfb305a90435da Mon Sep 17 00:00:00 2001 From: hhhello Date: Mon, 7 Oct 2024 19:10:11 +0900 Subject: [PATCH] Fix bugs --- .../graduatingserver/api/core/VoidRes.kt | 2 +- .../Network/Foundation/AuthInterceptor.swift | 26 ++++++++++++++----- .../EditGrade/EditGraduatingYearView.swift | 13 ++++++---- .../EditGraduatingYearViewModel.swift | 2 +- .../Onboarding/OnboardingThirdView.swift | 14 ++++++---- .../Onboarding/OnboardingViewModel.swift | 2 +- 6 files changed, 39 insertions(+), 20 deletions(-) diff --git a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/api/core/VoidRes.kt b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/api/core/VoidRes.kt index 356fb10..6d9c074 100644 --- a/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/api/core/VoidRes.kt +++ b/Graduating-Server/src/main/kotlin/com/bestswlkh0310/graduating/graduatingserver/api/core/VoidRes.kt @@ -1,3 +1,3 @@ package com.bestswlkh0310.graduating.graduatingserver.api.core -class VoidRes +class VoidRes \ No newline at end of file diff --git a/Graduating-iOS/Data/Network/Foundation/AuthInterceptor.swift b/Graduating-iOS/Data/Network/Foundation/AuthInterceptor.swift index b80e2ae..0d82f17 100644 --- a/Graduating-iOS/Data/Network/Foundation/AuthInterceptor.swift +++ b/Graduating-iOS/Data/Network/Foundation/AuthInterceptor.swift @@ -25,13 +25,17 @@ class AuthInterceptor: RequestInterceptor { completion: @escaping (RetryResult) -> Void ) { guard let response = request.task?.response as? HTTPURLResponse else { - completion(.doNotRetryWithError(error)) + DispatchQueue.main.async { + completion(.doNotRetryWithError(error)) + } return } guard request.retryCount <= 2 else { print("❌ AuthInterceptor - RetryCount가 2보다 큽니다") - completion(.doNotRetryWithError(APIError.refreshFailure)) + DispatchQueue.main.async { + completion(.doNotRetryWithError(APIError.refreshFailure)) + } return } @@ -40,12 +44,16 @@ class AuthInterceptor: RequestInterceptor { let tokenExpiredStatusCode = 403 guard response.statusCode == tokenExpiredStatusCode else { print("❌ AuthInterceptor - HTTP statusCode is not \(tokenExpiredStatusCode)") - completion(.doNotRetryWithError(error)) + DispatchQueue.main.async { + completion(.doNotRetryWithError(error)) + } return } guard let refreshToken = Sign.me.refreshToken else { print("❌ AuthInterceptor - refreshToken is nil") - completion(.doNotRetryWithError(APIError.refreshFailure)) + DispatchQueue.main.async { + completion(.doNotRetryWithError(APIError.refreshFailure)) + } return } @@ -53,11 +61,15 @@ class AuthInterceptor: RequestInterceptor { .init(refreshToken: refreshToken) ).sink { if case .failure = $0 { - completion(.doNotRetryWithError(APIError.refreshFailure)) + DispatchQueue.main.async { + completion(.doNotRetryWithError(APIError.refreshFailure)) + } } } receiveValue: { token in - Sign.me.reissue(token.accessToken) - completion(.retry) + DispatchQueue.main.async { + Sign.me.reissue(token.accessToken) + completion(.retry) + } }.store(in: &subscription) } } diff --git a/Graduating-iOS/Graduating/Feature/EditGrade/EditGraduatingYearView.swift b/Graduating-iOS/Graduating/Feature/EditGrade/EditGraduatingYearView.swift index bf41c05..34ac997 100644 --- a/Graduating-iOS/Graduating/Feature/EditGrade/EditGraduatingYearView.swift +++ b/Graduating-iOS/Graduating/Feature/EditGrade/EditGraduatingYearView.swift @@ -11,6 +11,7 @@ struct EditGraduatingYearView: View { @StateObject private var viewModel = EditGraduatingYearViewModel() private let path: Path + private let currentYear = Date.now[.year]! public init(path: Path) { self.path = path @@ -25,13 +26,15 @@ extension EditGraduatingYearView { .myFont(.title1B) .foreground(Colors.Label.normal) .frame(maxWidth: .infinity, alignment: .leading) - Picker("Graduating Year", selection: $viewModel.graduatingYear) { - ForEach(Date.now[.year]!...2100, id: \.self) { number in - Text(String(number)) - .myFont(.headling2M) + if let limit = appState.currentUser.data?.school.type?.limit { + Picker("Graduating Year", selection: $viewModel.graduatingYear) { + ForEach((currentYear + 1)...(currentYear + limit), id: \.self) { number in + Text(String(number)) + .myFont(.headling2M) + } } + .pickerStyle(.wheel) } - .pickerStyle(.wheel) Spacer() MyButton("다음", expanded: true, action: handleSubmit) .padding(.bottom, 10) diff --git a/Graduating-iOS/Graduating/Feature/EditGrade/EditGraduatingYearViewModel.swift b/Graduating-iOS/Graduating/Feature/EditGrade/EditGraduatingYearViewModel.swift index 2fe3174..da903b0 100644 --- a/Graduating-iOS/Graduating/Feature/EditGrade/EditGraduatingYearViewModel.swift +++ b/Graduating-iOS/Graduating/Feature/EditGrade/EditGraduatingYearViewModel.swift @@ -8,7 +8,7 @@ import Shared final class EditGraduatingYearViewModel: ObservableObject { private var subscriptions = Set() - @Published var graduatingYear = Date.now[.year]! + @Published var graduatingYear = Date.now[.year]! + 1 @Published var editGraduatingYearFlow = Flow.idle func editGraduatingYear() { diff --git a/Graduating-iOS/Graduating/Feature/Onboarding/OnboardingThirdView.swift b/Graduating-iOS/Graduating/Feature/Onboarding/OnboardingThirdView.swift index 05a3ee9..945e371 100644 --- a/Graduating-iOS/Graduating/Feature/Onboarding/OnboardingThirdView.swift +++ b/Graduating-iOS/Graduating/Feature/Onboarding/OnboardingThirdView.swift @@ -7,8 +7,10 @@ struct OnboardingThirdView { @EnvironmentObject private var router: Router @EnvironmentObject private var viewModel: OnboardingViewModel + @EnvironmentObject private var appState: AppState private let path: Path + private let currentYear = Date.now[.year]! public init(path: Path) { self.path = path @@ -23,13 +25,15 @@ extension OnboardingThirdView: View { .myFont(.title1B) .foreground(Colors.Label.normal) .frame(maxWidth: .infinity, alignment: .leading) - Picker("Graduating Year", selection: $viewModel.graduatingYear) { - ForEach(1900...2100, id: \.self) { number in - Text(String(number)) - .myFont(.headling2M) + if let limit = appState.currentUser.data?.school.type?.limit { + Picker("Graduating Year", selection: $viewModel.graduatingYear) { + ForEach((currentYear + 1)...(currentYear + limit), id: \.self) { number in + Text(String(number)) + .myFont(.headling2M) + } } + .pickerStyle(.wheel) } - .pickerStyle(.wheel) Spacer() MyButton("다음", expanded: true, action: handleSubmit) .padding(.bottom, 10) diff --git a/Graduating-iOS/Graduating/Feature/Onboarding/OnboardingViewModel.swift b/Graduating-iOS/Graduating/Feature/Onboarding/OnboardingViewModel.swift index 209658f..d36bcb8 100644 --- a/Graduating-iOS/Graduating/Feature/Onboarding/OnboardingViewModel.swift +++ b/Graduating-iOS/Graduating/Feature/Onboarding/OnboardingViewModel.swift @@ -13,7 +13,7 @@ final class OnboardingViewModel: ObservableObject { @Published var platformType: PlatformType? @Published var email: String? @Published var school: School? - @Published var graduatingYear = Date.now[.year] ?? 1900 + @Published var graduatingYear = Date.now[.year]! + 1 @Published var nickname: String = "" @Published var signUpFlow: Resource = .idle @Published var signInFlow: Resource = .idle