Skip to content

Commit

Permalink
⚡️ :: 이슈 3종 처리 (#340, #341, #342)
Browse files Browse the repository at this point in the history
Build v2.0.0(43)
  • Loading branch information
KangTaeHoon committed Jun 28, 2023
1 parent 783c31f commit d7187a7
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,15 @@ extension ContainSongsViewController {
.observe(on: MainScheduler.instance)
.subscribe(onNext: { [weak self] (result:AddSongEntity) in
guard let self = self else {return}

self.showToast(text: result.description, font: DesignSystemFontFamily.Pretendard.light.font(size: 14))

if result.status == 401 {
LOGOUT()
PlayState.shared.switchPlayerMode(to: .mini)
self.dismiss(animated: true) { [weak self] in
guard let self else {return}
self.delegate?.tokenExpired()
}

}else{
NotificationCenter.default.post(name: .playListRefresh, object: nil) // 플리목록창 이름 변경하기 위함
self.dismiss(animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,30 @@ public final class ContainSongsViewModel: ViewModelType {
}
return self.addSongIntoPlayListUseCase
.execute(key: key, songs: self.songs)
.catch({ (error:Error) in

.catch({ (error: Error) in
let wmError = error.asWMError

if wmError == .tokenExpired {
return Single<AddSongEntity>.create { single in
single(.success(AddSongEntity(status: 401,added_songs_length: 0, duplicated:false, description: wmError.errorDescription ?? "")))
single(.success(AddSongEntity(status: 401, added_songs_length: 0, duplicated: false, description: wmError.errorDescription ?? "")))
return Disposables.create()
}
}

else if wmError == .badRequest {
}else if wmError == .badRequest {
return Single<AddSongEntity>.create { single in
single(.success(AddSongEntity(status: 400,added_songs_length: 0, duplicated:true, description:"이미 내 리스트에 담긴 곡들입니다.")))
single(.success(AddSongEntity(status: 400, added_songs_length: 0, duplicated: false, description: wmError.errorDescription ?? "")))
return Disposables.create {}
}
}

else {
}else if wmError == .conflict {
return Single<AddSongEntity>.create { single in
single(.success(AddSongEntity(status: 500,added_songs_length: 0, duplicated:false, description:"서버에서 문제가 발생하였습니다.\n잠시 후 다시 시도해주세요!")))
single(.success(AddSongEntity(status: 409, added_songs_length: 0, duplicated: true, description: "이미 내 리스트에 담긴 곡들입니다.")))
return Disposables.create {}
}
}else {
return Single<AddSongEntity>.create { single in
single(.success(AddSongEntity(status: 500, added_songs_length: 0, duplicated: false, description: "서버에서 문제가 발생하였습니다.\n잠시 후 다시 시도해주세요!")))
return Disposables.create {}
}
}

})
.asObservable()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ extension PlayerViewModel {

/// 좋아요 상태 가져오기
func fetchLikeState(for song: SongEntity, output: Output) {
guard Utility.PreferenceManager.userInfo != nil else {
DEBUG_LOG("💡 비로그인 상태입니다. 로그인 후 가능합니다.")
output.likeState.send(false)
return
}
fetchFavoriteSongsUseCase.execute()
.catchAndReturn([])
.map { $0.contains { $0.song.id == song.id } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ final public class IntroViewModel: ViewModelType {
.withLatestFrom(Utility.PreferenceManager.$userInfo)
.filter{ (userInfo) in
guard userInfo != nil else {
///비로그인 상태인데, 키체인에 저장된 엑세스 토큰이 살아있다는건 로그인 상태로 앱을 삭제한 유저임
let keychain = KeychainImpl()
let accessToken = keychain.load(type: .accessToken)
if !accessToken.isEmpty {
DEBUG_LOG("💡 비로그인 상태입니다. 엑세스 토큰을 삭제합니다.")
keychain.delete(type: .accessToken)
}
output.userInfoResult.onNext(.success(""))
return false
}
Expand Down
27 changes: 13 additions & 14 deletions Projects/Modules/ErrorModule/Sources/WMError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ public enum WMError: Error, Equatable {
case custom(message: String = "알 수 없는 오류가 발생하였습니다", code: Int = 500)
case badRequest
case tokenExpired
case forbidden
case notFound
case conflict
case tooManyRequest
case internalServerError
case offline
Expand All @@ -16,26 +18,23 @@ extension WMError: LocalizedError {
switch self {
case .unknown:
return "알 수 없는 오류가 발생하였습니다."

case let .custom(message, _):
return message

case .badRequest:
case .badRequest: // 400
return "요청이 잘못되었습니다."

case .notFound: //404
return "요청한 것을 찾을 수 없습니다."

case .tokenExpired: //401
case .tokenExpired: // 401
return "인증이 만료되었습니다.\n다시 로그인해 주세요."

case .tooManyRequest:
case .forbidden: // 403
return "접근 권한이 없습니다."
case .notFound: // 404
return "요청한 것을 찾을 수 없습니다."
case .conflict: // 409
return "요청이 이미 존재합니다."
case .tooManyRequest: // 429
return "요청 횟수를 초과했습니다.\n잠시 후 다시 시도해주세요!"

case .internalServerError:
case .internalServerError: // 500
return "서버에서 문제가 발생하였습니다.\n잠시 후 다시 시도해주세요!"

case .offline:
case .offline: // 1009
return "인터넷 연결이 오프라인입니다.\n네트워크 상태를 확인해주세요."
}
}
Expand Down
1 change: 1 addition & 0 deletions Projects/Services/APIKit/Sources/API/PlayListAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ extension PlayListAPI: WMAPI {
400: .badRequest,
401: .tokenExpired,
404: .notFound,
409: .conflict,
429: .tooManyRequest,
500: .internalServerError
]
Expand Down
2 changes: 1 addition & 1 deletion Tuist/ProjectDescriptionHelpers/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public enum Environment {
public static let platform = Platform.iOS
public static let baseSetting: SettingsDictionary = SettingsDictionary()
.marketingVersion("2.0.0")
.currentProjectVersion("42")
.currentProjectVersion("43")
.debugInformationFormat(DebugInformationFormat.dwarfWithDsym)
.otherLinkerFlags(["-ObjC"])
.bitcodeEnabled(false)
Expand Down

0 comments on commit d7187a7

Please sign in to comment.