Skip to content

Refactor/#336 2차스프린트 2차 QA 반영#337

Merged
y-eonee merged 5 commits intodevelopfrom
refactor/#336-2차-qa
Dec 4, 2025

Hidden character warning

The head ref may contain hidden characters: "refactor/#336-2\ucc28-qa"
Merged

Refactor/#336 2차스프린트 2차 QA 반영#337
y-eonee merged 5 commits intodevelopfrom
refactor/#336-2차-qa

Conversation

@y-eonee
Copy link
Collaborator

@y-eonee y-eonee commented Dec 2, 2025

🔗 연결된 이슈

📄 작업 내용

  • 2차스프린트의2차큐에이! 를 작업했습니다.
  • 퀘스트를 10자 이상 입력하지 않았는데 완료 버튼 enable 상태(최초 작성 상태/수정 상태 모두)
  • 행동형 최초 작성 시 사진을 등록하지 않고 텍스트만 입력했는데 완료 버튼 enable 상태로 변경됨
구현 내용 질문형 큐에이 - 수정 질문형 큐에이 - 최초작성
GIF
구현 내용 행동형 큐에이
GIF

💻 주요 코드 설명

protocol QuestCompleteProtocol: AnyObject {
    func changeCount(count: Int) // 이미지 카운트를 변경할 때만 사용합니다. 
    func updateButtonWhenWriting(text: String) // 텍스트 관련 ui 업데이트 시 사용합니다 
}

extension QuestCompleteProtocol {
    func changeCount(count: Int) { return } // 질문형일때는 이 함수가 필요없으므로 익스텐션으로 리턴처리 해주었습니다 
}
extension WriteQuestionTypeQuestViewController: QuestCompleteProtocol {
    func updateButtonWhenWriting(text: String) {
        switch questMode {
        case .write:
            if isValidAnswerText(text: text){
                rootView.confirmButton.updateType(.enabled)
            } else {
                rootView.confirmButton.updateType(.disabled)
            }
            
        case .edit:
            if answerText != text && isValidAnswerText(text: text) {
                rootView.confirmButton.updateType(.enabled)
            } else {
                rootView.confirmButton.updateType(.disabled)
            }
        }
    }
}

extension WriteQuestionTypeQuestViewController {
    private func isValidAnswerText(text: String) -> Bool {
        if (text.count >= 10) &&
            (!rootView.questTextField.textView.text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) {
            return true
        } else {
            return false
        }
    }
}

기존에 10자 이상 + 공백 제거 관련 조건이 뷰 코드에 있었는데 뷰보다는 뷰컨트롤러에 있는게 좀 더 맞다고 판단되어 뷰컨트롤러로 옮겼습니다.
프로토콜 관련 함수를 리팩토링하면서 질문형 뷰컨에 있던 함수도 같이 리팩토링했습니다.
questmode에 따라 분기처리를 해주면서 버튼타입을 업데이트시켜줍니다.

@y-eonee y-eonee self-assigned this Dec 2, 2025
@y-eonee y-eonee linked an issue Dec 2, 2025 that may be closed by this pull request
1 task
@y-eonee y-eonee added the refactor 기존 코드 리팩토링 label Dec 2, 2025
Copy link
Collaborator

@dev-domo dev-domo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고 많으셨습니다! 리뷰가 있긴 하나 수정한 기능은 잘 돌아가는 걸로 보여 어푸 드립니다~

}

extension WriteQuestionTypeQuestViewController {
private func isValidAnswerText(text: String) -> Bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

답변의 유효성을 따로 메서드로 분리한 거 좋네요! 다만 뷰컨트롤러는 UI를 업데이트시키는 데에만 집중하고, 답변의 유효성 검증은 뷰모델 쪽으로 책임을 분리해보면 어떨까요? 답변 유효성을 검증해주는 유스케이스도 만들어 볼 수 있을 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다!!!!

@@ -6,11 +6,10 @@
//

protocol QuestCompleteProtocol: AnyObject {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존에 만들어두신 EditQuestProtocol에 메서드를 추가하는 대신 QuestCompleteProtocol을 따로 정의한 이유가 있는지 궁금합니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

원래 기존에는 QuestCompleteProtocol이 있고 수정기능을 추가하면서 edit protocol을 만들었는데요!
리팩토링을 하다보니 텍스트필드 유효성을 검증해서 완료버튼을 누르기까지의 과정은 수정과 기존 쓰기 버전이 둘이 비슷하다고 생각하여 관련로직은 Complete 프로토콜에 작성했습니다..!! edit protocol에는 처음 수정으로 들어갈 때 관련 정보를 불러오는 것을 수행합니다!

Copy link
Collaborator

@juri123123 juri123123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

승준이가 코멘트 확인해보면 좋을 것 같아요 ~ 고생많으셨습니다 !

Copy link
Collaborator

@dev-domo dev-domo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

너무 잘봤습니다! 고생 많으셨어용

}
}

private func isValidText(previousText: String, changingText: String) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 if-else문을 최대한 안 쓰는 편이라 아래처럼 해도 괜찮을 것 같아요. 참고만 해주세용!

let isValidText: Bool = isValidQuestAnswerUseCase.execute(previousText: previousText, changingText: changingText)
isValidSubject.send(isValidText)

@y-eonee y-eonee force-pushed the refactor/#336-2차-qa branch from ad8c203 to e0a6fbc Compare December 4, 2025 02:26
@y-eonee y-eonee merged commit fd4bbd2 into develop Dec 4, 2025
1 check passed
@y-eonee y-eonee deleted the refactor/#336-2차-qa branch December 4, 2025 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor 기존 코드 리팩토링 나연🐹

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor] 2차 QA

3 participants