Parcourir la Source

Show today’s date under schedule header instead of first due date

Replace scheduleHeadingText (derived from first todo) with scheduleTodayHeadingText so the join and schedule page date lines reflect the current calendar day. Use the same formatted heading while loading when Google is connected.

Made-with: Cursor
huzaifahayat12 il y a 1 semaine
Parent
commit
2b4266be8b
1 fichiers modifiés avec 7 ajouts et 11 suppressions
  1. 7 11
      classroom_app/ViewController.swift

+ 7 - 11
classroom_app/ViewController.swift

@@ -6574,11 +6574,11 @@ private extension ViewController {
6574 6574
     }
6575 6575
 
6576 6576
     private func scheduleInitialHeadingText() -> String {
6577
-        googleOAuth.loadTokens() == nil ? "Connect Google to see your to-do" : "Loading…"
6577
+        googleOAuth.loadTokens() == nil ? "Connect Google to see your to-do" : scheduleTodayHeadingText()
6578 6578
     }
6579 6579
 
6580 6580
     private func schedulePageInitialHeadingText() -> String {
6581
-        googleOAuth.loadTokens() == nil ? "Connect Google to see your to-do" : "Loading to-do…"
6581
+        googleOAuth.loadTokens() == nil ? "Connect Google to see your to-do" : scheduleTodayHeadingText()
6582 6582
     }
6583 6583
 
6584 6584
     private func enrolledPageInitialHeadingText() -> String {
@@ -6693,17 +6693,13 @@ private extension ViewController {
6693 6693
         return f.string(from: due)
6694 6694
     }
6695 6695
 
6696
-    private func scheduleHeadingText(for todos: [ClassroomTodoItem]) -> String {
6697
-        guard let first = todos.first else {
6698
-            return googleOAuth.loadTokens() == nil ? "Connect Google to see to-do" : "No upcoming work"
6699
-        }
6700
-        guard let due = first.dueDate else { return "No due dates" }
6701
-        let day = Calendar.current.startOfDay(for: due)
6696
+    private func scheduleTodayHeadingText() -> String {
6697
+        let today = Calendar.current.startOfDay(for: Date())
6702 6698
         let f = DateFormatter()
6703 6699
         f.locale = Locale.current
6704 6700
         f.timeZone = TimeZone.current
6705 6701
         f.dateFormat = "EEEE, d MMM"
6706
-        return f.string(from: day)
6702
+        return f.string(from: today)
6707 6703
     }
6708 6704
 
6709 6705
     private func enrolledPageHeadingText(for courses: [ClassroomCourse]) -> String {
@@ -7194,7 +7190,7 @@ private extension ViewController {
7194 7190
         schedulePageFilteredTodos = filteredTodosForSchedulePage(scheduleCachedTodos)
7195 7191
         schedulePageVisibleCount = min(schedulePageBatchSize, schedulePageFilteredTodos.count)
7196 7192
         renderSchedulePageCards()
7197
-        schedulePageDateHeadingLabel?.stringValue = scheduleHeadingText(for: schedulePageFilteredTodos)
7193
+        schedulePageDateHeadingLabel?.stringValue = scheduleTodayHeadingText()
7198 7194
     }
7199 7195
 
7200 7196
     private func appendSchedulePageBatchIfNeeded() {
@@ -7339,7 +7335,7 @@ private extension ViewController {
7339 7335
             await MainActor.run {
7340 7336
                 updateGoogleAuthButtonTitle()
7341 7337
                 applyGoogleProfile(profile.map { self.makeGoogleProfileDisplay(from: $0) })
7342
-                scheduleDateHeadingLabel?.stringValue = scheduleHeadingText(for: filtered)
7338
+                scheduleDateHeadingLabel?.stringValue = scheduleTodayHeadingText()
7343 7339
                 if let stack = scheduleCardsStack {
7344 7340
                     renderScheduleCards(into: stack, todos: filtered)
7345 7341
                 }