Fix production crash points, actor-isolation warnings, and rebrand URLs
Remove all fatalError/force unwrap/force cast crash points from production
paths (ShowBasedOnVoteLogics, Random, ReflectApp, NoteEditorView). Fix
actor-isolation warnings by wrapping off-main-thread AnalyticsManager calls
in Task { @MainActor in } (LocalNotification) and replacing DispatchQueue
with Task.detached + MainActor.run (LiveActivityPreviewView). Update legal
URLs from feels.88oakapps.com to reflect.88oakapps.com in SettingsView.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -21,10 +21,14 @@ class LocalNotification {
|
||||
public class func testIfEnabled(completion: @escaping (Result<Bool, Error>) -> Void) {
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, error in
|
||||
if success {
|
||||
AnalyticsManager.shared.track(.notificationEnabled)
|
||||
Task { @MainActor in
|
||||
AnalyticsManager.shared.track(.notificationEnabled)
|
||||
}
|
||||
completion(.success(true))
|
||||
} else if let error = error {
|
||||
AnalyticsManager.shared.track(.notificationDisabled)
|
||||
Task { @MainActor in
|
||||
AnalyticsManager.shared.track(.notificationDisabled)
|
||||
}
|
||||
completion(.failure(error))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ struct Constants {
|
||||
struct GroupUserDefaults {
|
||||
static var groupDefaults: UserDefaults {
|
||||
#if DEBUG
|
||||
return UserDefaults(suiteName: Constants.groupShareIdDebug)!
|
||||
return UserDefaults(suiteName: Constants.groupShareIdDebug) ?? .standard
|
||||
#else
|
||||
return UserDefaults(suiteName: Constants.groupShareId)!
|
||||
return UserDefaults(suiteName: Constants.groupShareId) ?? .standard
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class Random {
|
||||
static var existingDayFormat = [NSNumber: String]()
|
||||
static func dayFormat(fromDate date: Date) -> String {
|
||||
let components = Calendar.current.dateComponents([.day], from: date)
|
||||
let day = components.day!
|
||||
let day = components.day ?? 1
|
||||
|
||||
let formatter = NumberFormatter()
|
||||
formatter.numberStyle = .ordinal
|
||||
@@ -411,18 +411,18 @@ final class DateFormattingCache {
|
||||
|
||||
extension Bundle {
|
||||
var appName: String {
|
||||
return infoDictionary?["CFBundleName"] as! String
|
||||
return infoDictionary?["CFBundleName"] as? String ?? "Reflect"
|
||||
}
|
||||
|
||||
var bundleId: String {
|
||||
return bundleIdentifier!
|
||||
return bundleIdentifier ?? "com.88oakapps.reflect"
|
||||
}
|
||||
|
||||
var versionNumber: String {
|
||||
return infoDictionary?["CFBundleShortVersionString"] as! String
|
||||
return infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0"
|
||||
}
|
||||
|
||||
var buildNumber: String {
|
||||
return infoDictionary?["CFBundleVersion"] as! String
|
||||
return infoDictionary?["CFBundleVersion"] as? String ?? "0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ struct ReflectApp: App {
|
||||
|
||||
BGTaskScheduler.shared.cancelAllTaskRequests()
|
||||
BGTaskScheduler.shared.register(forTaskWithIdentifier: BGTask.updateDBMissingID, using: nil) { (task) in
|
||||
BGTask.runFillInMissingDatesTask(task: task as! BGProcessingTask)
|
||||
guard let processingTask = task as? BGProcessingTask else { return }
|
||||
BGTask.runFillInMissingDatesTask(task: processingTask)
|
||||
}
|
||||
UNUserNotificationCenter.current().setBadgeCount(0)
|
||||
|
||||
|
||||
@@ -90,11 +90,7 @@ class ShowBasedOnVoteLogics {
|
||||
date = Calendar.current.date(byAdding: .day, value: -1, to: now)
|
||||
}
|
||||
|
||||
guard let date = date else {
|
||||
fatalError("missing getCurrentVotingDate")
|
||||
}
|
||||
|
||||
return date
|
||||
return date ?? now
|
||||
}
|
||||
|
||||
static public func getVotingTitle(onboardingData: OnboardingData, now: Date = Date()) -> String {
|
||||
@@ -106,7 +102,7 @@ class ShowBasedOnVoteLogics {
|
||||
return String(localized: "add_mood_header_view_title_today")
|
||||
|
||||
case (false, .Previous):
|
||||
let date = Calendar.current.date(byAdding: .day, value: -2, to: now)!
|
||||
let date = Calendar.current.date(byAdding: .day, value: -2, to: now) ?? now
|
||||
return String(format: String(localized: "add_mood_header_view_title"), Random.weekdayName(fromDate: date))
|
||||
case (true, .Previous):
|
||||
return String(localized: "add_mood_header_view_title_yesterday")
|
||||
|
||||
@@ -478,9 +478,9 @@ struct EntryDetailView: View {
|
||||
Button("Choose from Library") {
|
||||
showPhotoPicker = true
|
||||
}
|
||||
if entry.photoID != nil {
|
||||
if let photoID = entry.photoID {
|
||||
Button("Remove Photo", role: .destructive) {
|
||||
_ = PhotoManager.shared.deletePhoto(id: entry.photoID!)
|
||||
_ = PhotoManager.shared.deletePhoto(id: photoID)
|
||||
_ = DataController.shared.updatePhoto(forDate: entry.forDate, photoID: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,9 +321,12 @@ struct LiveActivityRecordingView: View {
|
||||
exportPath = outputDir.path
|
||||
print("📁 Exporting frames to: \(exportPath)")
|
||||
|
||||
// Export frames on background queue
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
for streak in 1...targetStreak {
|
||||
let target = targetStreak
|
||||
let outDir = outputDir
|
||||
let outPath = exportPath
|
||||
|
||||
Task.detached(priority: .userInitiated) {
|
||||
for streak in 1...target {
|
||||
let mood = getMoodForStreak(streak)
|
||||
|
||||
let cardView = LiveActivityCardView(
|
||||
@@ -337,21 +340,21 @@ struct LiveActivityRecordingView: View {
|
||||
|
||||
if let uiImage = renderer.uiImage {
|
||||
let filename = String(format: "frame_%04d.png", streak)
|
||||
let fileURL = outputDir.appendingPathComponent(filename)
|
||||
let fileURL = outDir.appendingPathComponent(filename)
|
||||
|
||||
if let pngData = uiImage.pngData() {
|
||||
try? pngData.write(to: fileURL)
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
await MainActor.run {
|
||||
exportProgress = streak
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
await MainActor.run {
|
||||
exportComplete = true
|
||||
print("✅ Export complete! \(targetStreak) frames saved to: \(exportPath)")
|
||||
print("✅ Export complete! \(target) frames saved to: \(outPath)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1030,7 +1030,7 @@ struct SettingsContentView: View {
|
||||
private var eulaButton: some View {
|
||||
Button(action: {
|
||||
AnalyticsManager.shared.track(.eulaViewed)
|
||||
if let url = URL(string: "https://feels.88oakapps.com/eula.html") {
|
||||
if let url = URL(string: "https://reflect.88oakapps.com/eula.html") {
|
||||
UIApplication.shared.open(url)
|
||||
}
|
||||
}, label: {
|
||||
@@ -1049,7 +1049,7 @@ struct SettingsContentView: View {
|
||||
private var privacyButton: some View {
|
||||
Button(action: {
|
||||
AnalyticsManager.shared.track(.privacyPolicyViewed)
|
||||
if let url = URL(string: "https://feels.88oakapps.com/privacy.html") {
|
||||
if let url = URL(string: "https://reflect.88oakapps.com/privacy.html") {
|
||||
UIApplication.shared.open(url)
|
||||
}
|
||||
}, label: {
|
||||
@@ -1757,7 +1757,7 @@ struct SettingsView: View {
|
||||
private var eulaButton: some View {
|
||||
Button(action: {
|
||||
AnalyticsManager.shared.track(.eulaViewed)
|
||||
openURL(URL(string: "https://feels.88oakapps.com/eula.html")!)
|
||||
if let url = URL(string: "https://reflect.88oakapps.com/eula.html") { openURL(url) }
|
||||
}, label: {
|
||||
Text(String(localized: "settings_view_show_eula"))
|
||||
.foregroundColor(textColor)
|
||||
@@ -1772,7 +1772,7 @@ struct SettingsView: View {
|
||||
private var privacyButton: some View {
|
||||
Button(action: {
|
||||
AnalyticsManager.shared.track(.privacyPolicyViewed)
|
||||
openURL(URL(string: "https://feels.88oakapps.com/privacy.html")!)
|
||||
if let url = URL(string: "https://reflect.88oakapps.com/privacy.html") { openURL(url) }
|
||||
}, label: {
|
||||
Text(String(localized: "settings_view_show_privacy"))
|
||||
.foregroundColor(textColor)
|
||||
|
||||
Reference in New Issue
Block a user