Skip to content

Commit

Permalink
fix: tear down timers on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
a11rew committed Nov 22, 2023
1 parent b3b9639 commit 3940ee7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Calendar Focus Sync.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 10 additions & 3 deletions Calendar Focus Sync/Services/SyncOrchestrator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ class SyncOrchestrator {
}

deinit {
for (_, timer) in activeFocusModeTimers {
timer.invalidate()
}
tearDownTimers()
}

@MainActor
Expand All @@ -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 {
Expand Down

0 comments on commit 3940ee7

Please sign in to comment.