-
Notifications
You must be signed in to change notification settings - Fork 1
주간 시간표 #200
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
주간 시간표 #200
Conversation
Walkthrough주간 시간표 기능이 추가되어 Core와 View가 신설되고 MainCore/MainView에 연결되었습니다. Remote Config를 도입해 enable_weekly_time_table 플래그로 일간/주간 시간표 표시를 토글합니다. 부가적으로 일간 시간표 안내 문구, 학교 설정 버튼 문구가 변경되었고, 사용자 속성에 새 키가 추가되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant MainView
participant MainCore
participant WeeklyTimeTableCore as WeeklyCore
participant RemoteConfig
participant TimeTableClient as API
participant LocalDB
Note over RemoteConfig,MainView: Remote Config 플래그 로드
RemoteConfig-->>MainView: enable_weekly_time_table
MainView->>MainCore: onAppear
MainCore->>MainCore: weeklyTimeTableCore 생성 (displayDate 공유)
MainView->>WeeklyCore: .onLoad / .onAppear
WeeklyCore->>WeeklyCore: displayDate 변경 구독 → refreshData
WeeklyCore->>WeeklyCore: mondayDate 계산, 주말 표시 여부 결정
alt 수정 시간표 사용
WeeklyCore->>LocalDB: 수정 시간표 조회
LocalDB-->>WeeklyCore: 일자별 데이터
else 기본 시간표 사용
WeeklyCore->>API: 요일별 시간표 조회 (취소 토큰 포함)
API-->>WeeklyCore: 일자별 데이터
end
WeeklyCore->>WeeklyCore: 주간 구조로 집계(weekdays/dates/periods/subjects/todayIndex)
WeeklyCore-->>MainView: 상태 업데이트(loading/weeklyTimeTable)
Note over MainView: 플래그 변경 시 사용자 속성 로깅
sequenceDiagram
autonumber
participant RemoteConfig
participant MainView
participant TWLog
RemoteConfig-->>MainView: enable_weekly_time_table 값
MainView->>TWLog: setUserProperty(enable_weekly_time_table, value)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Successful finished SwiftLint |
✅ PR의 Assign 자동 지정을 성공했어요! |
Summary of ChangesHello @baekteun, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 사용자에게 주간 시간표를 제공하는 새로운 기능을 도입합니다. 이 기능은 Firebase Remote Config를 통해 유연하게 관리될 수 있으며, 기존 시간표 모듈의 구조를 개선하고 사용자 경험을 위한 사소한 UI 텍스트 조정을 포함합니다. 전반적으로 시간표 관련 기능의 확장성과 유용성을 향상시키는 데 중점을 둡니다. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
주간 시간표 기능을 추가하는 PR이네요. 전반적으로 새로운 기능이 잘 통합되었고, 기능 플래그를 사용하여 점진적으로 기능을 배포하는 방식도 좋습니다. 몇 가지 코드 개선 사항을 제안합니다. WeeklyTimeTableCore에서 데이터를 병렬로 가져오도록 수정하여 성능을 개선하고, 일부 로직을 더 간결하게 만들어 가독성과 유지보수성을 높일 수 있습니다. 자세한 내용은 각 파일에 남긴 주석을 확인해주세요.
| for i in 0..<dayCount { | ||
| let currentDate = calendar.date(byAdding: .day, value: i, to: mondayDate) ?? mondayDate | ||
| let weekday = calendar.component(.weekday, from: currentDate) | ||
|
|
||
| let isOnModifiedTimeTable = userDefaultsClient.getValue(.isOnModifiedTimeTable) as? Bool ?? false | ||
|
|
||
| if isOnModifiedTimeTable { | ||
| let modifiedTimeTables = try? localDatabaseClient.readRecords(as: ModifiedTimeTableLocalEntity.self) | ||
| .filter { $0.weekday == weekday } | ||
|
|
||
| if let modifiedTimeTables, !modifiedTimeTables.isEmpty { | ||
| let timeTables = modifiedTimeTables | ||
| .sorted { $0.perio < $1.perio } | ||
| .map { TimeTable(perio: $0.perio, content: $0.content) } | ||
| weeklyData[i] = timeTables | ||
| } else { | ||
| weeklyData[i] = [] | ||
| } | ||
| } else { | ||
| do { | ||
| let dayData = try await timeTableClient.fetchTimeTable(currentDate) | ||
| weeklyData[i] = dayData | ||
| } catch { | ||
| weeklyData[i] = [] | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for 루프 내에서 await를 사용하여 각 날짜의 시간표를 순차적으로 가져오고 있습니다. 이로 인해 네트워크 상태가 좋지 않을 경우 상당한 지연이 발생할 수 있습니다. 각 날짜의 데이터를 가져오는 작업은 서로 독립적이므로 TaskGroup을 사용하여 병렬로 처리하면 성능을 크게 향상시킬 수 있습니다.
await withTaskGroup(of: (Int, [TimeTable]).self) { group in
for i in 0..<dayCount {
group.addTask {
let currentDate = calendar.date(byAdding: .day, value: i, to: mondayDate) ?? mondayDate
let weekday = calendar.component(.weekday, from: currentDate)
let isOnModifiedTimeTable = userDefaultsClient.getValue(.isOnModifiedTimeTable) as? Bool ?? false
if isOnModifiedTimeTable {
let modifiedTimeTables = try? localDatabaseClient.readRecords(as: ModifiedTimeTableLocalEntity.self)
.filter { $0.weekday == weekday }
if let modifiedTimeTables, !modifiedTimeTables.isEmpty {
let timeTables = modifiedTimeTables
.sorted { $0.perio < $1.perio }
.map { TimeTable(perio: $0.perio, content: $0.content) }
return (i, timeTables)
} else {
return (i, [])
}
} else {
do {
let dayData = try await timeTableClient.fetchTimeTable(currentDate)
return (i, dayData)
} catch {
return (i, [])
}
}
}
}
for await (index, timeTables) in group {
weeklyData[index] = timeTables
}
}| if showWeekend { | ||
| switch todayWeekday { | ||
| case 2: todayIndex = 0 // 월요일 | ||
| case 3: todayIndex = 1 // 화요일 | ||
| case 4: todayIndex = 2 // 수요일 | ||
| case 5: todayIndex = 3 // 목요일 | ||
| case 6: todayIndex = 4 // 금요일 | ||
| case 7: todayIndex = 5 // 토요일 | ||
| case 1: todayIndex = 6 // 일요일 | ||
| default: todayIndex = nil | ||
| } | ||
| } else { | ||
| switch todayWeekday { | ||
| case 2: todayIndex = 0 // 월요일 | ||
| case 3: todayIndex = 1 // 화요일 | ||
| case 4: todayIndex = 2 // 수요일 | ||
| case 5: todayIndex = 3 // 목요일 | ||
| case 6: todayIndex = 4 // 금요일 | ||
| default: todayIndex = nil | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재 todayIndex를 계산하는 로직이 switch 문으로 인해 길고 장황합니다. 수학적 계산을 사용하여 이 로직을 더 간결하게 만들 수 있습니다. 이렇게 하면 코드 가독성과 유지보수성이 향상됩니다.
if showWeekend {
// 1(일) -> 6, 2(월) -> 0, ..., 7(토) -> 5
todayIndex = (todayWeekday + 5) % 7
} else if (2...6).contains(todayWeekday) { // 월(2) ~ 금(6)
todayIndex = todayWeekday - 2
} else {
todayIndex = nil
}| selectedColumnPeriodCount: { | ||
| if let todayIndex = weeklyTimeTable | ||
| .todayIndex { weeklyTimeTable.actualPeriodCount(for: todayIndex) | ||
| } else { | ||
| 0 | ||
| } | ||
| }() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Projects/Feature/SchoolSettingFeature/Sources/SchoolSettingCore.swift (1)
44-51: nextButtonTitle 조건이 중복되어 논리 오류 및 도달 불가 코드가 있습니다
- 두 번째 조건의
|| schoolMajorList.isEmpty는 첫 번째 조건과 중복으로 의미가 없습니다.- 마지막
return "다음"은 실행 경로가 없습니다.간결하고 의도에 맞게 정리해주세요.
- public var nextButtonTitle: String { - if major.isEmpty || schoolMajorList.isEmpty { - return "이대로하기" - } else if !major.isEmpty || schoolMajorList.isEmpty { - return "확인!" - } - return "다음" - } + public var nextButtonTitle: String { + if major.isEmpty || schoolMajorList.isEmpty { + return "이대로하기" + } else { + return "확인!" + } + }
🧹 Nitpick comments (11)
Projects/App/iOS/Sources/Application/AppDelegate.swift (1)
8-8: 불필요한 import 가능성
FirebaseRemoteConfig를 이 파일에서 직접 사용하지 않습니다. 필요 없다면 제거해 주세요. Remote Config 초기화/활성화는featureFlagClient.activate()로 처리되고 있습니다.Projects/Feature/MainFeature/Sources/MainView.swift (1)
222-224: 최초 값 로깅 추가 제안현재는 플래그 변경 시에만 사용자 속성을 기록합니다. 최초 진입 시 값도 기록하면 분석 일관성이 좋아집니다. 아래처럼
.onAppear에 한 줄 추가를 권장합니다..onAppear { viewStore.send(.onAppear, animation: .default) + TWLog.setUserProperty(property: .enableWeeklyTimeTable, value: enableWeeklyTimeTable.description) }Projects/Feature/TimeTableFeature/Sources/Weekly/WeeklyTimeTableView.swift (2)
8-9: ColumnBorder.borderWidth 미사용 정리borderWidth를 선언하지만 path/stroke에서 사용하지 않습니다. 혼동을 줄이기 위해 제거하거나 stroke의 lineWidth와 일치시키세요. 제거안을 제안합니다.
권장 패치:
private struct ColumnBorder: Shape { - var borderWidth: CGFloat var cornerRadius: CGFloat @@ ColumnBorder( - borderWidth: 1, cornerRadius: 16, selectedColumnIndex: weeklyTimeTable.todayIndex, headerHeight: 44, firstColumnWidth: 40, columnWidth: columnWidth(weeklyTimeTable: weeklyTimeTable), useFlexibleWidth: shouldUseFlexibleWidth(weeklyTimeTable: weeklyTimeTable), columnCount: weeklyTimeTable.weekdays.count, cellHeight: 56, selectedColumnPeriodCount: { if let todayIndex = weeklyTimeTable .todayIndex { weeklyTimeTable.actualPeriodCount(for: todayIndex) } else { 0 } }() ) .stroke(Color.extraBlack.opacity(0.8), lineWidth: 2)Also applies to: 129-148
93-94: 불필요한 .frame(alignment:) 제거크기 지정 없는 .frame(alignment:)는 효과가 없습니다. 제거해도 동작 동일합니다.
권장 패치:
- timeTableGrid(weeklyTimeTable: weeklyTimeTable) - .frame(alignment: .top) + timeTableGrid(weeklyTimeTable: weeklyTimeTable) @@ - timeTableGrid(weeklyTimeTable: weeklyTimeTable) - .frame(alignment: .top) + timeTableGrid(weeklyTimeTable: weeklyTimeTable)Also applies to: 97-98
Projects/Feature/TimeTableFeature/Sources/Weekly/WeeklyTimeTableCore.swift (7)
18-18: 옵셔널의 불필요한 명시적 nil 초기화 제거SwiftLint 경고: = nil 제거 권장.
권장 패치:
- public var weeklyTimeTable: WeeklyTimeTable? = nil + public var weeklyTimeTable: WeeklyTimeTable?
130-133: 빈 연관값 와일드카드 제거.failure(_)에서 인자 미사용 시 괄호 생략 가능합니다. SwiftLint 권고 반영.
권장 패치:
- case .timeTableResponse(.failure(_)): + case .timeTableResponse(.failure): state.weeklyTimeTable = nil state.isLoading = false
65-71: for-where로 간결화단일 if는 for-where로 단순화해 SwiftLint 경고 해소.
권장 패치:
- for i in (0..<daySubjects.count).reversed() { - if !daySubjects[i].isEmpty { - return i + 1 - } - } + for i in (0..<daySubjects.count).reversed() where !daySubjects[i].isEmpty { + return i + 1 + } return 0
182-187: SwiftLint blanket disable 축소blanket disable 대신 next 사용으로 범위 최소화.
권장 패치:
- // swiftlint: disable cyclomatic_complexity + // swiftlint:disable:next cyclomatic_complexity private func createWeeklyTableFromAPIData(
141-152: 불변 플래그 루프 외부 호이스팅isOnModifiedTimeTable는 반복마다 동일합니다. 루프 밖으로 이동해 불필요한 호출을 줄이세요.
권장 패치:
private func fetchWeeklyTimeTable(mondayDate: Date, showWeekend: Bool) async throws -> WeeklyTimeTable { let calendar = Calendar.current let dayCount = showWeekend ? 7 : 5 var weeklyData: [Int: [TimeTable]] = [:] + let isOnModifiedTimeTable = userDefaultsClient.getValue(.isOnModifiedTimeTable) as? Bool ?? false for i in 0..<dayCount { let currentDate = calendar.date(byAdding: .day, value: i, to: mondayDate) ?? mondayDate let weekday = calendar.component(.weekday, from: currentDate) - let isOnModifiedTimeTable = userDefaultsClient.getValue(.isOnModifiedTimeTable) as? Bool ?? false
153-172: DB/네트워크 퍼포먼스 개선 제안
- DB: 매일 readRecords 후 필터링은 비효율적입니다. 한 번만 읽어 weekday별로 그룹핑하거나 쿼리 단계에서 weekday로 필터링하세요.
- 네트워크: showWeekend가 false/true에 따라 5~7회 순차 호출합니다. withTaskGroup 등으로 병렬화해 총 대기 시간을 줄이세요.
예시(개념):
// DB 한 번만 로드 후 사용 let allModified = (try? localDatabaseClient.readRecords(as: ModifiedTimeTableLocalEntity.self)) ?? [] let byWeekday = Dictionary(grouping: allModified, by: { $0.weekday }) // 네트워크 병렬화 (개념) try await withThrowingTaskGroup(of: (Int, [TimeTable]).self) { group in for i in 0..<dayCount { group.addTask { let date = calendar.date(byAdding: .day, value: i, to: mondayDate) ?? mondayDate return (i, try await timeTableClient.fetchTimeTable(date)) } } for try await (i, dayData) in group { weeklyData[i] = dayData } }
183-268: 긴 함수 분리 권장(createWeeklyTableFromAPIData)SwiftLint function_body_length 경고가 있습니다. 날짜 생성, 과목 매트릭스 구성, todayIndex 계산을 소함수로 분리해 가독성과 테스트 용이성을 높이세요.
간단한 분할 예:
- makeWeekdays(showWeekend:)
- makeDates(mondayDate:showWeekend:)
- buildSubjects(weeklyData:dayCount:)
- computeTodayIndex(mondayDate:showWeekend:)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
Projects/App/iOS/Sources/Application/AppDelegate.swift(1 hunks)Projects/Feature/MainFeature/Sources/MainCore.swift(4 hunks)Projects/Feature/MainFeature/Sources/MainView.swift(4 hunks)Projects/Feature/SchoolSettingFeature/Sources/SchoolSettingCore.swift(1 hunks)Projects/Feature/TimeTableFeature/Sources/Daily/TimeTableView.swift(1 hunks)Projects/Feature/TimeTableFeature/Sources/Weekly/WeeklyTimeTableCore.swift(1 hunks)Projects/Feature/TimeTableFeature/Sources/Weekly/WeeklyTimeTableView.swift(1 hunks)Projects/Shared/TWLog/Sources/TWUserProperty.swift(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
Projects/Feature/TimeTableFeature/Sources/Weekly/WeeklyTimeTableView.swift (1)
Projects/Feature/TimeTableFeature/Sources/Weekly/WeeklyTimeTableCore.swift (3)
actualPeriodCount(62-71)isToday(58-60)subject(49-56)
Projects/Feature/TimeTableFeature/Sources/Weekly/WeeklyTimeTableCore.swift (1)
Projects/Shared/LocalDatabaseClient/Sources/LocalDatabaseClient.swift (1)
readRecords(25-32)
Projects/Feature/MainFeature/Sources/MainView.swift (1)
Projects/Shared/TWLog/Sources/TWLog.swift (3)
event(63-68)setUserProperty(49-53)setUserProperty(55-57)
🪛 GitHub Check: swiftlint
Projects/Feature/TimeTableFeature/Sources/Weekly/WeeklyTimeTableCore.swift
[warning] 18-18:
Implicit Optional Initialization Violation: Optional should be implicitly initialized without nil (implicit_optional_initialization)
[warning] 183-183:
Function Body Length Violation: Function body should span 50 lines or less excluding comments and whitespace: currently spans 68 lines (function_body_length)
[warning] 66-66:
Prefer For-Where Violation: where clauses are preferred over a single if inside a for (for_where)
[warning] 130-130:
Empty Enum Arguments Violation: Arguments can be omitted when matching enums with associated values if they are not used (empty_enum_arguments)
[warning] 182-182:
Blanket Disable Command Violation: Use 'next', 'this' or 'previous' instead to disable the 'cyclomatic_complexity' rule once, or re-enable it as soon as possible` (blanket_disable_command)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: ⚙️ Prepare for CI
🔇 Additional comments (8)
Projects/Shared/TWLog/Sources/TWUserProperty.swift (1)
12-12: 사용자 속성 케이스 추가 적절합니다원격 플래그 로깅과 일관됩니다.
Projects/Feature/TimeTableFeature/Sources/Daily/TimeTableView.swift (1)
24-30: 학기 초 안내 문구 업데이트 LGTM3/9월 조건과 접근성 라벨이 일치합니다.
Projects/Feature/MainFeature/Sources/MainCore.swift (2)
119-121: 주간 시간표 리프레시 처리 확인 필요
mealCore(.refresh), timeTableCore(.refresh)만 날짜 정책 재적용을 트리거합니다. 주간 시간표도 유사한 경로(예:.weeklyTimeTableCore(.refresh))가 필요하다면 함께 처리해 주세요.
237-239: WeeklyTimeTableCore 서브리듀서 연결 LGTM상태/액션 라우팅이 올바르게 구성되었습니다.
Projects/Feature/MainFeature/Sources/MainView.swift (2)
62-78: 플래그 기반 주간/일간 전환 렌더링 LGTM스토어 스코핑과 조건부 렌더링이 일관됩니다.
3-3:@RemoteConfigProperty모듈 import 확인 및 초기 로깅 보강
@RemoteConfigProperty가 선언된 모듈(예:FeatureFlagClient)을 해당 파일에 import했는지 검증하세요. 불필요한import FirebaseRemoteConfig는 제거를 고려해주세요.- 현재
onChange만 사용 중이라 뷰 최초 렌더링 시 값이 기록되지 않습니다.onAppear에서 초기 값을 로깅하도록 추가하세요.Projects/Feature/TimeTableFeature/Sources/Weekly/WeeklyTimeTableView.swift (2)
72-79: Date().month 확장 존재 여부 확인 필요Swift 표준에는 Date.month가 없습니다. 확장이 없다면 빌드 실패합니다. 없으면 Calendar.current.component(.month, from:)로 대체하세요.
권장 패치:
- if Date().month == 3 || Date().month == 9 { + if Calendar.current.component(.month, from: Date()) == 3 + || Calendar.current.component(.month, from: Date()) == 9 {
105-107: 커스텀 .onLoad 사용 확인.onLoad가 커스텀 수정자인지 확인해주세요. 없다면 호출되지 않습니다. iOS 15+에서는 .task로 대체할 수 있습니다.
권장 패치:
- .onLoad { - viewStore.send(.onLoad) - } + .task { + viewStore.send(.onLoad) + }
| case .onAppear, .refreshData: | ||
| state.isLoading = true | ||
| state.showWeekend = | ||
| !(userDefaultsClient.getValue(.isSkipWeekend) as? Bool ?? false) | ||
|
|
||
| let baseDate = state.displayDate | ||
| let calendar = Calendar.current | ||
| let weekday = calendar.component(.weekday, from: baseDate) | ||
| let daysFromMonday = (weekday + 5) % 7 | ||
| let mondayDate = | ||
| calendar.date(byAdding: .day, value: -daysFromMonday, to: baseDate) | ||
| ?? baseDate | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull-to-Refresh 미동작: .refresh 액션 미처리
View에서 .refresh를 보냅니다만 reducer가 처리하지 않아 새로고침이 동작하지 않습니다. .refresh를 .refreshData와 동일하게 처리하세요.
권장 패치:
- case .onAppear, .refreshData:
+ case .onAppear, .refresh, .refreshData:
state.isLoading = true
state.showWeekend =
!(userDefaultsClient.getValue(.isSkipWeekend) as? Bool ?? false)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| case .onAppear, .refreshData: | |
| state.isLoading = true | |
| state.showWeekend = | |
| !(userDefaultsClient.getValue(.isSkipWeekend) as? Bool ?? false) | |
| let baseDate = state.displayDate | |
| let calendar = Calendar.current | |
| let weekday = calendar.component(.weekday, from: baseDate) | |
| let daysFromMonday = (weekday + 5) % 7 | |
| let mondayDate = | |
| calendar.date(byAdding: .day, value: -daysFromMonday, to: baseDate) | |
| ?? baseDate | |
| case .onAppear, .refresh, .refreshData: | |
| state.isLoading = true | |
| state.showWeekend = | |
| !(userDefaultsClient.getValue(.isSkipWeekend) as? Bool ?? false) | |
| let baseDate = state.displayDate | |
| let calendar = Calendar.current | |
| let weekday = calendar.component(.weekday, from: baseDate) | |
| let daysFromMonday = (weekday + 5) % 7 | |
| let mondayDate = | |
| calendar.date(byAdding: .day, value: -daysFromMonday, to: baseDate) | |
| ?? baseDate |
🤖 Prompt for AI Agents
In Projects/Feature/TimeTableFeature/Sources/Weekly/WeeklyTimeTableCore.swift
around lines 95 to 107, the reducer handles .onAppear and .refreshData but not
the View's .refresh action, so pull-to-refresh does nothing; update the switch
case to include .refresh (e.g., case .onAppear, .refresh, .refreshData:) or add
a separate case for .refresh that performs the identical work (set
state.isLoading = true, compute/showWeekend, compute mondayDate from
state.displayDate, etc.), ensuring .refresh triggers the same flow as
.refreshData.
| let today = Date() | ||
| let todayWeekday = calendar.component(.weekday, from: today) | ||
| let todayIndex: Int? | ||
|
|
||
| if showWeekend { | ||
| switch todayWeekday { | ||
| case 2: todayIndex = 0 // 월요일 | ||
| case 3: todayIndex = 1 // 화요일 | ||
| case 4: todayIndex = 2 // 수요일 | ||
| case 5: todayIndex = 3 // 목요일 | ||
| case 6: todayIndex = 4 // 금요일 | ||
| case 7: todayIndex = 5 // 토요일 | ||
| case 1: todayIndex = 6 // 일요일 | ||
| default: todayIndex = nil | ||
| } | ||
| } else { | ||
| switch todayWeekday { | ||
| case 2: todayIndex = 0 // 월요일 | ||
| case 3: todayIndex = 1 // 화요일 | ||
| case 4: todayIndex = 2 // 수요일 | ||
| case 5: todayIndex = 3 // 목요일 | ||
| case 6: todayIndex = 4 // 금요일 | ||
| default: todayIndex = nil | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오늘 하이라이트(todayIndex) 계산 오류
현재 Date()의 요일만으로 todayIndex를 계산해 표시 주와 무관하게 하이라이트됩니다. 표시 중인 주(mondayDate) 범위 내일 때만 인덱스를 계산해야 합니다.
권장 패치:
- let today = Date()
- let todayWeekday = calendar.component(.weekday, from: today)
- let todayIndex: Int?
-
- if showWeekend {
- switch todayWeekday {
- case 2: todayIndex = 0 // 월요일
- case 3: todayIndex = 1 // 화요일
- case 4: todayIndex = 2 // 수요일
- case 5: todayIndex = 3 // 목요일
- case 6: todayIndex = 4 // 금요일
- case 7: todayIndex = 5 // 토요일
- case 1: todayIndex = 6 // 일요일
- default: todayIndex = nil
- }
- } else {
- switch todayWeekday {
- case 2: todayIndex = 0 // 월요일
- case 3: todayIndex = 1 // 화요일
- case 4: todayIndex = 2 // 수요일
- case 5: todayIndex = 3 // 목요일
- case 6: todayIndex = 4 // 금요일
- default: todayIndex = nil
- }
- }
+ let startOfMonday = calendar.startOfDay(for: mondayDate)
+ let startOfToday = calendar.startOfDay(for: Date())
+ let diff = calendar.dateComponents([.day], from: startOfMonday, to: startOfToday).day ?? Int.max
+ let todayIndex: Int? = {
+ if showWeekend {
+ return (0...6).contains(diff) ? diff : nil
+ } else {
+ return (0...4).contains(diff) ? diff : nil
+ }
+ }()
💡 개요
주간 시간표
📃 작업내용
X
🔀 변경사항
🙋♂️ 질문사항
🍴 사용방법
🤔 고민과 해결방법
🎸 기타
Summary by CodeRabbit
신기능
스타일