From 3940ee79930d3d0bae93452cf460fb247e7511d2 Mon Sep 17 00:00:00 2001 From: Andrew Glago Date: Wed, 22 Nov 2023 22:17:02 +0000 Subject: [PATCH] fix: tear down timers on exit --- Calendar Focus Sync.xcodeproj/project.pbxproj | 8 ++++++-- Calendar Focus Sync/Services/SyncOrchestrator.swift | 13 ++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Calendar Focus Sync.xcodeproj/project.pbxproj b/Calendar Focus Sync.xcodeproj/project.pbxproj index ee41419..0febfb4 100644 --- a/Calendar Focus Sync.xcodeproj/project.pbxproj +++ b/Calendar Focus Sync.xcodeproj/project.pbxproj @@ -503,6 +503,7 @@ COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; DEAD_CODE_STRIPPING = YES; + DEVELOPMENT_TEAM = UP7DQ4WSUA; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "Calendar Focus Sync/Info.plist"; @@ -514,7 +515,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 0.1; + MARKETING_VERSION = 0.2; PRODUCT_BUNDLE_IDENTIFIER = "com.andrewglago.Calendar-Focus-Sync"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -529,10 +530,12 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGN_ENTITLEMENTS = "Calendar Focus Sync/Calendar Focus SyncRelease.entitlements"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; DEAD_CODE_STRIPPING = YES; + DEVELOPMENT_TEAM = UP7DQ4WSUA; ENABLE_HARDENED_RUNTIME = YES; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; @@ -545,7 +548,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 0.1; + MARKETING_VERSION = 0.2; PRODUCT_BUNDLE_IDENTIFIER = "com.andrewglago.Calendar-Focus-Sync"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -580,6 +583,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEAD_CODE_STRIPPING = YES; + DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; MACOSX_DEPLOYMENT_TARGET = 14.0; MARKETING_VERSION = 1.0; diff --git a/Calendar Focus Sync/Services/SyncOrchestrator.swift b/Calendar Focus Sync/Services/SyncOrchestrator.swift index 567a221..50a5e63 100644 --- a/Calendar Focus Sync/Services/SyncOrchestrator.swift +++ b/Calendar Focus Sync/Services/SyncOrchestrator.swift @@ -75,9 +75,7 @@ class SyncOrchestrator { } deinit { - for (_, timer) in activeFocusModeTimers { - timer.invalidate() - } + tearDownTimers() } @MainActor @@ -93,10 +91,19 @@ class SyncOrchestrator { } } + func tearDownTimers() { + for (_, timer) in activeFocusModeTimers { + timer.invalidate() + } + } + func syncCalendarEvents() async -> [CalendarEvent] { // Clear existing events await eventsHolder.clear() + // Tear down existing timers + tearDownTimers() + // Run handlers concurrently await withTaskGroup(of: [CalendarEvent].self) { group in for handler in calendarSyncHandlers {