Skip to content

Commit

Permalink
feat: Network Error 처리 추가 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
rlarjsdn3 committed Oct 2, 2024
1 parent 16e4c44 commit a35a1a4
Show file tree
Hide file tree
Showing 19 changed files with 612 additions and 319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,20 @@ final public class CommentViewReactor: Reactor {
Observable<Mutation>.just(.scrollTableToLast(true))
)
}
.catch { [weak self] error -> Observable<Mutation> in
Haptic.notification(type: .error)
self?.navigator.showFetchFailureToast()
return Observable.concat(
Observable<Mutation>.just(.setComments([])),
Observable<Mutation>.just(.setHiddenTablePrgressHud(true)),
Observable<Mutation>.just(.setHiddenNoneCommentView(true)),
Observable<Mutation>.just(.setHiddenFetchFailureView(false))
)
.catchWorkerError(with: self) {
switch $1 {
case .networkFailure:
Haptic.notification(type: .error)
$0.navigator.showFetchFailureToast()
return Observable.concat(
Observable<Mutation>.just(.setComments([])),
Observable<Mutation>.just(.setHiddenTablePrgressHud(true)),
Observable<Mutation>.just(.setHiddenNoneCommentView(true)),
Observable<Mutation>.just(.setHiddenFetchFailureView(false))
)

default: return Observable<Mutation>.empty()
}
}
)

Expand Down
16 changes: 16 additions & 0 deletions 14th-team5-iOS/Core/Sources/Extensions/Dictionary+Ext.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Dictionary+Ext.swift
// Core
//
// Created by 김건우 on 10/2/24.
//

import Foundation

public extension Dictionary where Key: RawRepresentable, Value: RawRepresentable {

func toQueryParameters() -> String {
map { (key, value) in "\(key.rawValue)=\(value.rawValue)" }.joined(separator: "&")
}

}
66 changes: 0 additions & 66 deletions 14th-team5-iOS/Core/Sources/Extensions/Observable+Ext.swift

This file was deleted.

14 changes: 0 additions & 14 deletions 14th-team5-iOS/Data/Sources/APIs/BBAPI.swift

This file was deleted.

24 changes: 0 additions & 24 deletions 14th-team5-iOS/Data/Sources/APIs/BBAPIConfiguration.swift

This file was deleted.

75 changes: 0 additions & 75 deletions 14th-team5-iOS/Data/Sources/APIs/BBAPIWorker.swift

This file was deleted.

23 changes: 0 additions & 23 deletions 14th-team5-iOS/Data/Sources/APIs/BBSession.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension CommentAPIWorker {
let sort = query.sort.rawValue
let spec = CommentAPIs.fetchPostComment(postId: postId, page: page, size: size, sort: sort).spec

return request(spec, of: PaginationResponsePostCommentResponseDTO.self)
return request(spec)
}


Expand All @@ -45,7 +45,7 @@ extension CommentAPIWorker {
) -> Observable<PostCommentResponseDTO> {
let spec = CommentAPIs.createPostComment(postId: postId, body: body).spec

return request(spec, of: PostCommentResponseDTO.self)
return request(spec)
}


Expand All @@ -58,7 +58,7 @@ extension CommentAPIWorker {
) -> Observable<PostCommentResponseDTO> {
let spec = CommentAPIs.updatePostComment(postId: postId, commentId: commentId).spec

return request(spec, of: PostCommentResponseDTO.self)
return request(spec)
}


Expand All @@ -70,7 +70,7 @@ extension CommentAPIWorker {
) -> Observable<PostCommentDeleteResponseDTO> {
let spec = CommentAPIs.deletePostComment(postId: postId, commentId: commentId).spec

return request(spec, of: PostCommentDeleteResponseDTO.self)
return request(spec)
}

}
Loading

0 comments on commit a35a1a4

Please sign in to comment.