Przeglądaj źródła

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 1 tydzień temu
rodzic
commit
2b4266be8b
1 zmienionych plików z 7 dodań i 11 usunięć
  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
     private func scheduleInitialHeadingText() -> String {
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
     private func schedulePageInitialHeadingText() -> String {
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
     private func enrolledPageInitialHeadingText() -> String {
6584
     private func enrolledPageInitialHeadingText() -> String {
@@ -6693,17 +6693,13 @@ private extension ViewController {
6693
         return f.string(from: due)
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
         let f = DateFormatter()
6698
         let f = DateFormatter()
6703
         f.locale = Locale.current
6699
         f.locale = Locale.current
6704
         f.timeZone = TimeZone.current
6700
         f.timeZone = TimeZone.current
6705
         f.dateFormat = "EEEE, d MMM"
6701
         f.dateFormat = "EEEE, d MMM"
6706
-        return f.string(from: day)
6702
+        return f.string(from: today)
6707
     }
6703
     }
6708
 
6704
 
6709
     private func enrolledPageHeadingText(for courses: [ClassroomCourse]) -> String {
6705
     private func enrolledPageHeadingText(for courses: [ClassroomCourse]) -> String {
@@ -7194,7 +7190,7 @@ private extension ViewController {
7194
         schedulePageFilteredTodos = filteredTodosForSchedulePage(scheduleCachedTodos)
7190
         schedulePageFilteredTodos = filteredTodosForSchedulePage(scheduleCachedTodos)
7195
         schedulePageVisibleCount = min(schedulePageBatchSize, schedulePageFilteredTodos.count)
7191
         schedulePageVisibleCount = min(schedulePageBatchSize, schedulePageFilteredTodos.count)
7196
         renderSchedulePageCards()
7192
         renderSchedulePageCards()
7197
-        schedulePageDateHeadingLabel?.stringValue = scheduleHeadingText(for: schedulePageFilteredTodos)
7193
+        schedulePageDateHeadingLabel?.stringValue = scheduleTodayHeadingText()
7198
     }
7194
     }
7199
 
7195
 
7200
     private func appendSchedulePageBatchIfNeeded() {
7196
     private func appendSchedulePageBatchIfNeeded() {
@@ -7339,7 +7335,7 @@ private extension ViewController {
7339
             await MainActor.run {
7335
             await MainActor.run {
7340
                 updateGoogleAuthButtonTitle()
7336
                 updateGoogleAuthButtonTitle()
7341
                 applyGoogleProfile(profile.map { self.makeGoogleProfileDisplay(from: $0) })
7337
                 applyGoogleProfile(profile.map { self.makeGoogleProfileDisplay(from: $0) })
7342
-                scheduleDateHeadingLabel?.stringValue = scheduleHeadingText(for: filtered)
7338
+                scheduleDateHeadingLabel?.stringValue = scheduleTodayHeadingText()
7343
                 if let stack = scheduleCardsStack {
7339
                 if let stack = scheduleCardsStack {
7344
                     renderScheduleCards(into: stack, todos: filtered)
7340
                     renderScheduleCards(into: stack, todos: filtered)
7345
                 }
7341
                 }