Skip to content

Commit ecbb956

Browse files
Show saved plans on dashboard
1 parent 9db726f commit ecbb956

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

Sources/SajiloApp/Core/Planner/DashboardUpNext.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ struct DashboardUpNext: Equatable, Sendable {
3838
return Self(kind: .plan(upcomingPlan), todayFestival: todayFestival, destination: .today)
3939
}
4040

41-
if let todayFestival {
42-
return Self(kind: .festival(todayFestival), todayFestival: todayFestival, destination: .today)
41+
if let untimedPlan = DayPlan.ordered(plans).first(where: { $0.time == nil }) {
42+
return Self(kind: .plan(untimedPlan), todayFestival: todayFestival, destination: .today)
4343
}
4444

45-
if let untimedPlan = DayPlan.ordered(plans).first(where: { $0.time == nil }) {
46-
return Self(kind: .plan(untimedPlan), todayFestival: nil, destination: .today)
45+
if let todayFestival {
46+
return Self(kind: .festival(todayFestival), todayFestival: todayFestival, destination: .today)
4747
}
4848

4949
if let nextFestival {

Tests/SajiloAppTests/DashboardUpNextTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ struct DashboardUpNextTests {
5555
#expect(summary?.destination == .today)
5656
}
5757

58+
@Test func usesAnUntimedPlanBeforeAFestivalToday() {
59+
let plan = DayPlan(date: NepaliDate(year: 2083, month: 4, day: 31), title: "Call home")
60+
let festival = event(name: "नाग पञ्चमी", daysAway: 0)
61+
62+
let summary = DashboardUpNext.make(plans: [plan], events: [festival], now: now)
63+
64+
#expect(summary?.kind == .plan(plan))
65+
#expect(summary?.todayFestival == festival)
66+
#expect(summary?.destination == .today)
67+
}
68+
5869
private func event(name: String, daysAway: Int) -> UpcomingEvent {
5970
UpcomingEvent(
6071
date: NepaliDate(year: 2083, month: 4, day: 31),

0 commit comments

Comments
 (0)