Skip to content

Commit

Permalink
Merge branch 'fix/#246-searchFix' into refactor/#242-recommendRefactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chaentopia committed Sep 12, 2023
2 parents bf409ab + 631d404 commit 34153b0
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 45 deletions.
6 changes: 3 additions & 3 deletions YELLO-iOS/YELLO-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2438,7 +2438,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.4.1;
MARKETING_VERSION = 1.4.2;
PRODUCT_BUNDLE_IDENTIFIER = YELLO.iOS.dev;
PRODUCT_NAME = "$(Yello_Bundle_Name)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -2599,7 +2599,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.4.1;
MARKETING_VERSION = 1.4.2;
PRODUCT_BUNDLE_IDENTIFIER = YELLO.iOS;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -2639,7 +2639,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.4.1;
MARKETING_VERSION = 1.4.2;
PRODUCT_BUNDLE_IDENTIFIER = YELLO.iOS;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
22 changes: 12 additions & 10 deletions YELLO-iOS/YELLO-iOS/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,21 @@ extension AppDelegate: MessagingDelegate {
print("FirebaseMessaging")
guard let fcmToken = fcmToken else { return }
let deviceToken:[String: String] = ["token": fcmToken]

let requestDTO = DeviceTokenRefreshRequestDTO(deviceToken: fcmToken)
NetworkService.shared.onboardingService.putRefreshDeviceToken(requsetDTO: requestDTO) { result in
switch result {
case .success(let data):
if data.status == 200 || data.status == 201 {
User.shared.deviceToken = fcmToken
if fcmToken != User.shared.deviceToken {
let requestDTO = DeviceTokenRefreshRequestDTO(deviceToken: fcmToken)
NetworkService.shared.onboardingService.putRefreshDeviceToken(requsetDTO: requestDTO) { result in
switch result {
case .success(let data):
if data.status == 200 || data.status == 201 {
User.shared.deviceToken = fcmToken
print("Device token 재발급 완료:", deviceToken)
}
default:
print("deviceToken 재발급 오류")
}
default:
print("deviceToken 재발급 오류")
}
}
User.shared.deviceToken = fcmToken
print("Device token 재발급 완료:", deviceToken)
print("Device token:", deviceToken)
}
}
5 changes: 1 addition & 4 deletions YELLO-iOS/YELLO-iOS/Network/Base/MyRequestInterceptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ final class MyRequestInterceptor: RequestInterceptor {
print("재발급 출발")

if retryCount < maxRetryCount {
let accessToken = KeychainHandler.shared.accessToken
let refreshToken = KeychainHandler.shared.refreshToken
let dto = TokenRefreshRequestDTO(accessToken: "Bearer \(accessToken)", refreshToken: "Bearer \(refreshToken)")

NetworkService.shared.onboardingService.postRefreshToken(requsetDTO: dto) { result in
NetworkService.shared.onboardingService.postRefreshToken() { result in
switch result {
case .success(let data):
guard let decodedData = data.data else { return }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ enum OnboardingTarget {
case getCheckDuplicate(_ dto: IdValidRequestQueryDTO) /// 아이디 중복 확인
case postFirendsList( _ query: JoinedFriendsRequestQueryDTO, _ dto: JoinedFriendsRequestDTO) /// 가입한 친구 목록 불러오기
case postUserInfo(_ dto: SignUpRequestDTO ) /// 회원가입
case postRefreshToken(_ dto: TokenRefreshRequestDTO)
case postRefreshToken
case putDeviceToken(_ dto: DeviceTokenRefreshRequestDTO)
}

Expand All @@ -36,7 +36,7 @@ extension OnboardingTarget: TargetType {
case .postUserInfo:
return .unauthorization
case .postRefreshToken:
return .unauthorization
return .authorization
case .putDeviceToken:
return .authorization
}
Expand Down Expand Up @@ -119,8 +119,8 @@ extension OnboardingTarget: TargetType {
return .requestQuery(dto)
case .postFirendsList(let query, let dto):
return .requestQueryWithBody(query, bodyParameter: dto)
case .postRefreshToken(let dto):
return .requestWithBody(dto)
case .postRefreshToken:
return .requestPlain
case .putDeviceToken(let dto):
return .requestWithBody(dto)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ protocol OnboardingServiceProtocol {
func getSchoolList(queryDTO: SchoolSearchRequestQueryDTO, completion: @escaping (NetworkResult<BaseResponse<SchoolSearchResponseDTO>>) -> Void)
func getMajorList(queryDTO: MajorSearchRequestQueryDTO, completion: @escaping (NetworkResult<BaseResponse<MajorSearchResponseDTO>>) -> Void)
func postJoinedFriends(queryDTO: JoinedFriendsRequestQueryDTO, requestDTO: JoinedFriendsRequestDTO, completion: @escaping (NetworkResult<BaseResponse<JoinedFriendsResponseDTO>>) -> Void)
func postRefreshToken(requsetDTO: TokenRefreshRequestDTO, completion: @escaping (NetworkResult<BaseResponse<TokenRefreshResponseDTO>>) -> Void)
func putRefreshDeviceToken(requsetDTO: DeviceTokenRefreshRequestDTO, completion: @escaping (NetworkResult<BaseResponse<String>>) ->Void)
func postRefreshToken(completion: @escaping (NetworkResult<BaseResponse<TokenRefreshResponseDTO>>) -> Void)
func putRefreshDeviceToken(requsetDTO: DeviceTokenRefreshRequestDTO, completion: @escaping (NetworkResult<BaseResponse<String>>) -> Void)

}

Expand Down Expand Up @@ -47,11 +47,11 @@ final class OnboardingService: APIRequestLoader<OnboardingTarget>, OnboardingSer
fetchData(target: .postFirendsList(queryDTO, requestDTO), responseData: BaseResponse<JoinedFriendsResponseDTO>.self, completion: completion)
}

func postRefreshToken(requsetDTO: TokenRefreshRequestDTO, completion: @escaping (NetworkResult<BaseResponse<TokenRefreshResponseDTO>>)->Void) {
fetchData(target: .postRefreshToken(requsetDTO), responseData: BaseResponse<TokenRefreshResponseDTO>.self, completion: completion)
func postRefreshToken(completion: @escaping (NetworkResult<BaseResponse<TokenRefreshResponseDTO>>) -> Void) {
fetchData(target: .postRefreshToken, responseData: BaseResponse<TokenRefreshResponseDTO>.self, completion: completion)
}

func putRefreshDeviceToken(requsetDTO: DeviceTokenRefreshRequestDTO, completion: @escaping (NetworkResult<BaseResponse<String>>)->Void) {
func putRefreshDeviceToken(requsetDTO: DeviceTokenRefreshRequestDTO, completion: @escaping (NetworkResult<BaseResponse<String>>) -> Void) {
fetchData(target: .putDeviceToken(requsetDTO), responseData: BaseResponse.self, completion: completion)
}

Expand Down
6 changes: 3 additions & 3 deletions YELLO-iOS/YELLO-iOS/Network/Search/Router/SearchTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Alamofire

@frozen
enum SearchTarget {
case friendSearch(_ dto: FriendSearchRequestQueryDTO) /// 학교 검색
case friendSearch(_ query: FriendSearchRequestQueryDTO)
}

extension SearchTarget: TargetType {
Expand Down Expand Up @@ -45,8 +45,8 @@ extension SearchTarget: TargetType {

var parameters: RequestParams {
switch self {
case .friendSearch(let dto):
return .requestQuery(dto)
case .friendSearch(let query):
return .requestQuery(query)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ final class PaymentPlusViewController: BaseViewController {
setDelegate()
getProducts()
setNotification()
purchaseSubscribeNeed()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

tabBarController?.tabBar.isHidden = true
paymentPlusView.paymentView.bannerTimer()
purchaseSubscribeNeed()
}

func getProducts() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,12 @@ extension ProfileViewController: HandleDeleteFriendButtonDelegate {
func deleteFriendButtonTapped() {
profileView.showToast(message: profileView.myProfileFriendModelDummy[profileView.indexNumber].name + StringLiterals.Profile.Friend.toastMessage)

friendProfileViewController.friendProfileView.profileDeleteFriend(id: profileView.myProfileFriendModelDummy[profileView.indexNumber].userId)
bottomSheetViewController.friendProfileView.profileDeleteFriend(id: profileView.myProfileFriendModelDummy[profileView.indexNumber].userId)

if #available(iOS 15.0, *) {
friendProfileViewController.friendProfileView.profileDeleteFriend(id: profileView.myProfileFriendModelDummy[profileView.indexNumber].userId)
} else {
bottomSheetViewController.friendProfileView.profileDeleteFriend(id: profileView.myProfileFriendModelDummy[profileView.indexNumber].userId)
}

// 삭제 작업이 적용된 후에 UI 업데이트
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
self.profileView.myProfileFriendModelDummy.remove(at: self.profileView.indexNumber)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class FriendSearchViewController: BaseViewController {
friendSearchView.friendSearchTextfield.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
}

func searchFriend(_ word: String) {
func searchFriend(_ word: String?) {
if fetchingMore { // 이미 데이터를 가져오는 중이면 리턴
return
}
Expand All @@ -70,7 +70,7 @@ final class FriendSearchViewController: BaseViewController {
return
}

let queryDTO: FriendSearchRequestQueryDTO = FriendSearchRequestQueryDTO(keyword: word, page: pageCount)
let queryDTO: FriendSearchRequestQueryDTO = FriendSearchRequestQueryDTO(keyword: word ?? "", page: pageCount)

self.fetchingMore = true
if !self.isScroll {
Expand All @@ -85,7 +85,12 @@ final class FriendSearchViewController: BaseViewController {
switch result {
case .success(let data):
guard let data = data.data else { return }
self.allFriend.append(contentsOf: data.friendList)
// 중복되는 모델 필터 처리
let uniqueFriendModels = data.friendList.filter { model in
!self.allFriend.contains { $0.id == model.id }
}

self.allFriend.append(contentsOf: uniqueFriendModels)
self.fetchingMore = false

if !self.isScroll {
Expand All @@ -96,15 +101,18 @@ final class FriendSearchViewController: BaseViewController {

self.totalItemCount = data.totalCount
if data.totalCount == 0 {
if word.isEmpty {
if word == "" {
// 전부 지웠을 때
self.allFriend.removeAll()
self.friendSearchView.noResultView.isHidden = true
self.friendSearchView.loadingStackView.isHidden = true
} else {
// 검색 결과 없을 때
self.allFriend.removeAll()
self.friendSearchView.noResultView.isHidden = false
}
} else {
// 검색 결과 있을 떄
self.friendSearchView.noResultView.isHidden = true
}

Expand Down Expand Up @@ -159,6 +167,7 @@ extension FriendSearchViewController: UITextFieldDelegate {
@objc func textFieldDidChange(_ textField: UITextField) {
guard let text = textField.text else { return }
isFinishPaging = false
fetchingMore = false
pageCount = 0
allFriend.removeAll()
searchFriend(text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,26 @@ extension VotingTimerViewController {
result in
switch result {
case .success(let data):
guard let data = data.data else { return }
if data.isPossible {
let viewController = VotingStartViewController()
viewController.myPoint = String(data.point)
UIView.transition(with: self.navigationController?.view ?? UIView(), duration: 0.001, options: .transitionCrossDissolve, animations: {
// 전환 시 스르륵 바뀌는 애니메이션 적용
self.navigationController?.pushViewController(viewController, animated: false)
})
let status = data.status
guard let data = data.data else {
if status == 400 {
let viewController = VotingLockedViewController()
UIView.transition(with: self.navigationController?.view ?? UIView(), duration: 0.001, options: .transitionCrossDissolve, animations: {
// 전환 시 스르륵 바뀌는 애니메이션 적용
self.navigationController?.pushViewController(viewController, animated: false)
})
}
return
}
if status == 200 {
if data.isPossible {
let viewController = VotingStartViewController()
viewController.myPoint = String(data.point)
UIView.transition(with: self.navigationController?.view ?? UIView(), duration: 0.001, options: .transitionCrossDissolve, animations: {
// 전환 시 스르륵 바뀌는 애니메이션 적용
self.navigationController?.pushViewController(viewController, animated: false)
})
}
}
self.myPoint = data.point
self.originView.topOfMyPoint.setTextWithLineHeight(text: String(self.myPoint), lineHeight: 24)
Expand Down

0 comments on commit 34153b0

Please sign in to comment.