Skip to content

Commit 5f110a1

Browse files
johankoolCopilot
andcommitted
Fix undo delegate witness matching
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6430487 commit 5f110a1

3 files changed

Lines changed: 2 additions & 21 deletions

File tree

Examples/Reminders/RemindersApp.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class RemindersSyncEngineDelegate: SyncEngineDelegate {
8989

9090
@MainActor
9191
@Observable
92-
final class RemindersUndoManagerDelegate: UndoManagerDelegate {
92+
final class RemindersUndoManagerDelegate: SQLiteData.UndoManagerDelegate {
9393
struct ConfirmationRequest: Identifiable {
9494
let action: UndoAction
9595
let group: UndoGroup
@@ -135,7 +135,7 @@ final class RemindersUndoManagerDelegate: UndoManagerDelegate {
135135
_ undoManager: SQLiteData.UndoManager,
136136
willPerform action: UndoAction,
137137
for group: UndoGroup,
138-
performAction: @Sendable () async throws -> Void
138+
performAction: @isolated(any) @Sendable () async throws -> Void
139139
) async throws {
140140
guard shouldConfirm(for: group) else {
141141
try await performAction()

Sources/SQLiteData/Undo/UndoManagerDelegate.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
/// The delegate can present a confirmation prompt, or perform any async work, before calling
44
/// `performAction` to commit the operation. If `performAction` is not called, the operation is
55
/// cancelled and the undo/redo stacks remain unchanged.
6-
///
7-
/// The default implementation performs the action immediately without any confirmation.
86
public protocol UndoManagerDelegate: AnyObject, Sendable {
97
/// Called before the undo manager performs an undo or redo operation.
108
///
@@ -13,24 +11,10 @@ public protocol UndoManagerDelegate: AnyObject, Sendable {
1311
/// - action: Whether this is an undo or redo.
1412
/// - group: The group of changes that will be undone or redone.
1513
/// - performAction: Call this to commit the operation. Omitting this call cancels it.
16-
@MainActor
1714
func undoManager(
1815
_ undoManager: SQLiteData.UndoManager,
1916
willPerform action: UndoAction,
2017
for group: UndoGroup,
2118
performAction: @Sendable () async throws -> Void
2219
) async throws
2320
}
24-
25-
extension UndoManagerDelegate {
26-
/// Default implementation: immediately performs the action without confirmation.
27-
@MainActor
28-
public func undoManager(
29-
_ undoManager: SQLiteData.UndoManager,
30-
willPerform action: UndoAction,
31-
for group: UndoGroup,
32-
performAction: @Sendable () async throws -> Void
33-
) async throws {
34-
try await performAction()
35-
}
36-
}

Tests/SQLiteDataTests/UndoTests/UndoManagerTests.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ extension DatabaseWriter where Self == DatabaseQueue {
396396
}
397397

398398
@Test func delegateCancel() async throws {
399-
@MainActor
400399
final class CancelDelegate: UndoManagerDelegate {
401400
func undoManager(
402401
_ undoManager: SQLiteData.UndoManager,
@@ -433,7 +432,6 @@ extension DatabaseWriter where Self == DatabaseQueue {
433432
}
434433
let capture = MetadataCapture()
435434

436-
@MainActor
437435
final class MetadataDelegate: UndoManagerDelegate, @unchecked Sendable {
438436
let capture: MetadataCapture
439437
init(_ capture: MetadataCapture) { self.capture = capture }
@@ -475,7 +473,6 @@ extension DatabaseWriter where Self == DatabaseQueue {
475473
}
476474
let capture = ActionCapture()
477475

478-
@MainActor
479476
final class ActionDelegate: UndoManagerDelegate, @unchecked Sendable {
480477
let capture: ActionCapture
481478
init(_ capture: ActionCapture) { self.capture = capture }

0 commit comments

Comments
 (0)