Skip to content

Commit d3779f2

Browse files
authored
Merge pull request #7 from r-token/bug/fix-monthly-off-by-one
Fix an off-by-one bug on the 'monthly' preference
2 parents d673871 + d52a792 commit d3779f2

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

CatchUp-SwiftUI.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@
504504
"$(inherited)",
505505
"@executable_path/Frameworks",
506506
);
507-
MARKETING_VERSION = 3.1.0;
507+
MARKETING_VERSION = 3.1.1;
508508
PRODUCT_BUNDLE_IDENTIFIER = com.tokensolutions.CatchUp;
509509
PRODUCT_NAME = CatchUp;
510510
SUPPORTS_MACCATALYST = NO;
@@ -532,7 +532,7 @@
532532
"$(inherited)",
533533
"@executable_path/Frameworks",
534534
);
535-
MARKETING_VERSION = 3.1.0;
535+
MARKETING_VERSION = 3.1.1;
536536
PRODUCT_BUNDLE_IDENTIFIER = com.tokensolutions.CatchUp;
537537
PRODUCT_NAME = CatchUp;
538538
SUPPORTS_MACCATALYST = NO;

CatchUp-SwiftUI/Utilities/Conversions.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,25 @@ struct Converter {
136136
let weekday: String
137137

138138
switch contact.notification_preference_weekday {
139-
case 0:
139+
case 1:
140140
weekday = "Sunday"
141141
break
142-
case 1:
142+
case 2:
143143
weekday = "Monday"
144144
break
145-
case 2:
145+
case 3:
146146
weekday = "Tuesday"
147147
break
148-
case 3:
148+
case 4:
149149
weekday = "Wednesday"
150150
break
151-
case 4:
151+
case 5:
152152
weekday = "Thursday"
153153
break
154-
case 5:
154+
case 6:
155155
weekday = "Friday"
156156
break
157-
case 6:
157+
case 7:
158158
weekday = "Saturday"
159159
break
160160
default:

CatchUp-SwiftUI/Utilities/NotificationHelper.swift

+4-5
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ struct NotificationHelper {
103103
} else if contact.preferenceIsWeekly() || contact.preferenceIsMonthly() {
104104
components.hour = contact.notification_preference_hour
105105
components.minute = contact.notification_preference_minute
106-
components.weekday = contact.notification_preference_weekday+1
106+
components.weekday = contact.notification_preference_weekday
107107
if contact.notification_preference_week_of_month != 0 {
108-
components.weekOfMonth = contact.notification_preference_week_of_month+1
108+
components.weekOfMonth = contact.notification_preference_week_of_month
109109
}
110110
} else if contact.preferenceIsQuarterly() {
111111
print("Quarterly is handled separately by UNTimeIntervalNotificationTrigger. Fallthrough.")
@@ -154,12 +154,11 @@ struct NotificationHelper {
154154
} else if contact.preferenceIsWeekly() {
155155
dateComponents.hour = contact.notification_preference_hour
156156
dateComponents.minute = contact.notification_preference_minute
157-
// weekday units are 1-7, I store them as 0-6 though. Need to add 1
158-
dateComponents.weekday = contact.notification_preference_weekday+1
157+
dateComponents.weekday = contact.notification_preference_weekday
159158
} else if contact.preferenceIsMonthly() {
160159
dateComponents.hour = contact.notification_preference_hour
161160
dateComponents.minute = contact.notification_preference_minute
162-
dateComponents.weekday = contact.notification_preference_weekday+1
161+
dateComponents.weekday = contact.notification_preference_weekday
163162
dateComponents.weekOfMonth = contact.notification_preference_week_of_month
164163
} else if contact.preferenceIsAnnually() || contact.preferenceIsCustom() {
165164
if contact.preferenceIsAnnually() {

CatchUp-SwiftUI/Views/DetailScreen Subviews/NotificationPreferenceView.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct NotificationPreferenceView: View {
4343
// Day of the Week Picker
4444
Picker(selection: $contact.notification_preference_weekday, label: Text(whatDayText)) {
4545
ForEach(0..<dayOptions.count, id: \.self) { index in
46-
Text(dayOptions[index].rawValue).tag(index)
46+
Text(dayOptions[index].rawValue).tag(index+1)
4747
}
4848
}
4949

@@ -93,13 +93,13 @@ struct NotificationPreferenceView: View {
9393
if newValue != initialNotificationPreference {
9494
print("contact.notification_preference changed")
9595
initialNotificationPreference = 999
96-
contact.notification_preference_week_of_month = .random(in: 2..<5)
9796

9897
if newValue == 2 { // weekly
9998
whatDayText = "What day?"
10099
contact.notification_preference_week_of_month = 0
101100
} else if newValue == 3 { // monthly
102101
whatDayText = "What day? We'll pick a random week."
102+
contact.notification_preference_week_of_month = .random(in: 2..<5)
103103
} else if newValue == 4 { // quarterly
104104
contact.notification_preference_quarterly_set_time = Date()
105105
print("scheduling quarterly time interval notification")

0 commit comments

Comments
 (0)