Skip to content

Commit

Permalink
[feat] #241: 채팅방 멤버 차단 API 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-muuu committed Jun 4, 2023
1 parent feb164b commit 983dd4c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class ChattingRoomViewController: BaseViewController<ChattingRoomHeaderVie

override func viewDidLoad() {
super.viewDidLoad()
viewModel.viewDidLoad()
viewModel.requestChattingMembers()
}

override func initialize() {
Expand Down Expand Up @@ -142,6 +142,16 @@ final class ChattingRoomViewController: BaseViewController<ChattingRoomHeaderVie
break
}
}.disposed(by: disposeBag)

output.blockResponse
.subscribe{ [weak self] response in
switch response {
case .success:
self?.viewModel.requestChattingMembers()
default:
break
}
}.disposed(by: disposeBag)
}

//MARK: - Action
Expand Down
16 changes: 12 additions & 4 deletions Zatch/Presentation/ViewModels/Chat/ChattingRoomViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import RxCocoa

protocol ChattingRoomViewModelInterface: BaseViewModel, BlockUserInterface{
var messages: [ChatMessage] { get }
func viewDidLoad()
func requestChattingMembers()
}

protocol BlockUserInterface{
Expand All @@ -21,7 +21,6 @@ protocol BlockUserInterface{
}

class ChattingRoomViewModel: ChattingRoomViewModelInterface{

var messages = [ChatMessage]()
var chattingmMembers = [ChattingMember]()

Expand Down Expand Up @@ -53,6 +52,7 @@ class ChattingRoomViewModel: ChattingRoomViewModelInterface{

struct Output{
// let canSendMessage: Driver<Bool>
let blockResponse: Observable<ResponseState>
let exitResponse: Observable<ResponseState>
}

Expand All @@ -63,10 +63,18 @@ class ChattingRoomViewModel: ChattingRoomViewModelInterface{
self.exitRoomUseCase.execute(roomId: self.roomId)
}

return Output(exitResponse: exitResponse)
let blockResponse = blockUserIndexSubject
.map{ index in
self.chattingmMembers[index].userId
}
.flatMap{ userId in
self.blockUserUseCase.execute(requestValue: BlockUserRequestModel(blockedUserId: userId))
}

return Output(blockResponse: blockResponse, exitResponse: exitResponse)
}

func viewDidLoad() {
func requestChattingMembers() {
//채팅방 멤버 조회
getChattingMemberListUseCase
.execute(roomId: roomId)
Expand Down

0 comments on commit 983dd4c

Please sign in to comment.