Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Network] #114 - 필터링 실시간 업데이트 #117

Merged
merged 5 commits into from
Jul 19, 2024
Merged

Conversation

mcrkgus
Copy link
Member

@mcrkgus mcrkgus commented Jul 19, 2024

🔥 Pull requests

👷 작업한 내용

  • Map Marker 실시간 필터링 반영
  • 필터링 실시간 업데이트
  • 대학교 선택 시 대학교 위치로 이동
  • universityId 연결
  • 필터링 Button 변경

🖥️ 주요 코드 설명

HomeViewModel, HomeViewController

  • Filtering 3가지(category, price, sort)를 모두 했을 경우와 각각의 경우를 나누어 분기처리 진행
  • 필터 선택 시 button 변경
  • 필터 선택 시 지도 marker와 홈화면의 족보 리스트를 실시간으로 반영하여 업데이트 하였음.
  • 근데, 너무 많은 호출이 발생하는 것 같아 뭔가 좋은 방법은 아니라고 생각함.
var hankkiLists: [GetHankkiListData] = [] {
        didSet {
            hankkiListsDidChange?(hankkiLists)
        }
    }
var hankkiPins: [GetHankkiPinData] = [] {
        didSet {
            hankkiPinsDidChange?(hankkiPins)
        }
    }

var hankkiListsDidChange: (([GetHankkiListData]) -> Void)?
var hankkiPinsDidChange: (([GetHankkiPinData]) -> Void)?

var storeCategory: String? {
        didSet { updateHankkiList() }
    }
    var priceCategory: String? {
        didSet { updateHankkiList() }
    }
    var sortOption: String? {
        didSet { updateHankkiList() }
    }
func updateHankkiList() {
        let storeCategory = storeCategory ?? ""
        let priceCategory = priceCategory ?? ""
        let sortOption = sortOption ?? ""
        
        guard let id = UserDefaults.standard.getUniversity()?.id else { return }

        getHankkiListAPI(universityid: id, storeCategory: storeCategory, priceCategory: priceCategory, sortOption: sortOption) { success in
            if success {
                print("식당 전체 족보 fetch 완료 ")
                self.getHankkiPinAPI(universityid: id, storeCategory: storeCategory, priceCategory: priceCategory, sortOption: sortOption) { pinSuccess in
                    if pinSuccess {
                        print("지도 핀 fetch 완료 😄")
                        self.hankkiPinsDidChange?(self.hankkiPins)
                    } else {
                        print("지도 핀 fetch 실패 😞")
                    }
                }
            } else {
                print("식당 족보 fetch 실패 ")
            }
        }
    }
self?.hankkiLists = response?.data.stores ?? []
self?.hankkiListsDidChange?(self?.hankkiLists ?? [])
self?.hankkiPins = response?.data.pins ?? [] 
self?.hankkiPinsDidChange?(self?.hankkiPins ?? [])

✅ Check List

  • Merge 대상 브랜치가 올바른가?
  • 최종 코드가 에러 없이 잘 동작하는가?
  • 전체 변경사항이 500줄을 넘지 않는가?

📟 관련 이슈

@mcrkgus mcrkgus added 🛠️ Fix 버그, 오류 해결 🚨 review required 🚨 긴급긴급 빠르게 확인해야할 사항 💞 가현 가현 공주 작업 labels Jul 19, 2024
@mcrkgus mcrkgus self-assigned this Jul 19, 2024
Copy link
Contributor

@shimseohyun shimseohyun left a comment

Choose a reason for hiding this comment

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

개굿이옵니다 마마

Comment on lines 35 to +37
var hankkiListsDidChange: (([GetHankkiListData]) -> Void)?

private let universityid: Int = 1 // university api 연결 후 변경 예정

var hankkiPinsDidChange: (([GetHankkiPinData]) -> Void)?

Copy link
Contributor

Choose a reason for hiding this comment

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

좋은 방법인 것 같소

@mcrkgus mcrkgus merged commit 56449d0 into develop Jul 19, 2024
@mcrkgus mcrkgus deleted the network/#114 branch July 19, 2024 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💞 가현 가현 공주 작업 🛠️ Fix 버그, 오류 해결 🚨 review required 🚨 긴급긴급 빠르게 확인해야할 사항
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Network] 디테일 수정
2 participants