Skip to content

Commit

Permalink
Fix fetching evLecture id
Browse files Browse the repository at this point in the history
  • Loading branch information
peng-u-0807 committed Aug 13, 2024
1 parent cf9a2a4 commit 4cd34ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
8 changes: 3 additions & 5 deletions SNUTT-2022/SNUTT/Services/LectureService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ struct LectureService: LectureServiceProtocol {
}

func getEvLecture(of lecture: Lecture) async throws -> EvLecture? {
if let lectureId = lecture.lectureId {
let dto = try await reviewRepository.fetchEvLectureInfo(lectureId: lectureId)
return .init(from: dto)
}
return nil
let lectureId = lecture.lectureId ?? lecture.id
let dto = try await reviewRepository.fetchEvLectureInfo(lectureId: lectureId)
return .init(from: dto)
}

func getBuildingList(of lecture: Lecture) async throws -> [Building] {
Expand Down
16 changes: 8 additions & 8 deletions SNUTT-2022/SNUTT/Views/Scenes/LectureDetailScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ struct LectureDetailScene: View {
.onAppear {
isMapViewExpanded = viewModel.shouldOpenLectureMapView()
}
.onAppear {
Task {
if let evLecture = await viewModel.getEvLectureInfo(of: lecture) {
lecture.updateEvLecture(to: evLecture)
viewModel.reloadDetailWebView(detailId: evLecture.evLectureId)
}
}
}
.onChange(of: isMapViewExpanded) {
viewModel.setIsMapViewExpanded($0)
}
Expand Down Expand Up @@ -498,14 +506,6 @@ struct LectureDetailScene: View {
DetailButton(text: "강의평") {
showReviewWebView = true
}
.onAppear {
Task {
if let evLecture = await viewModel.getEvLectureInfo(of: lecture) {
lecture.updateEvLecture(to: evLecture)
viewModel.reloadDetailWebView(detailId: evLecture.evLectureId)
}
}
}
.sheet(isPresented: $showReviewWebView) {
ReviewScene(viewModel: .init(container: viewModel.container), isMainWebView: false, detailId: lecture.evLecture?.evLectureId)
.id(colorScheme)
Expand Down

0 comments on commit 4cd34ce

Please sign in to comment.