@@ -27,14 +27,32 @@ struct ScheduleFloatingPanelView: View {
27
27
@Binding var isShowingMyKSuiteUpgrade : Bool
28
28
29
29
let type : ScheduleType
30
+ let initialDate : Date ?
30
31
let completionHandler : ( Date ) -> Void
31
32
32
33
private var scheduleOptions : [ ScheduleOption ] {
34
+ var seenDateOptions = Set < Date > ( )
35
+ if let initialDate {
36
+ seenDateOptions. insert ( initialDate)
37
+ }
38
+
39
+ var filteredOptions = ScheduleOption . allPresetOptions. filter { option in
40
+ guard option. canBeDisplayed, let date = option. date else { return false }
41
+ if seenDateOptions. contains ( date) {
42
+ return false
43
+ } else {
44
+ seenDateOptions. insert ( date)
45
+ return true
46
+ }
47
+ }
48
+
33
49
let lastScheduledDate = UserDefaults . shared [ keyPath: type. lastCustomScheduleDateKeyPath]
50
+ let lastScheduledOption = ScheduleOption . lastSchedule ( value: lastScheduledDate)
51
+ if lastScheduledOption. canBeDisplayed, !seenDateOptions. contains ( lastScheduledDate) {
52
+ filteredOptions. insert ( . lastSchedule( value: lastScheduledDate) , at: 0 )
53
+ }
34
54
35
- var allSimpleCases = ScheduleOption . allPresetOptions
36
- allSimpleCases. insert ( ScheduleOption . lastSchedule ( value: lastScheduledDate) , at: 0 )
37
- return allSimpleCases. filter { $0. canBeDisplayed }
55
+ return filteredOptions
38
56
}
39
57
40
58
var body : some View {
@@ -58,6 +76,7 @@ struct ScheduleFloatingPanelView: View {
58
76
ScheduleFloatingPanelView (
59
77
isShowingCustomScheduleAlert: . constant( false ) ,
60
78
isShowingMyKSuiteUpgrade: . constant( false ) ,
61
- type: . scheduledDraft
79
+ type: . scheduledDraft,
80
+ initialDate: nil
62
81
) { _ in }
63
82
}
0 commit comments