|
82 | 82 | defaultZone: defaultZone, |
83 | 83 | privateTables: privateTables |
84 | 84 | ) |
| 85 | + SyncMetadata |
| 86 | + .where { |
| 87 | + $0.recordPrimaryKey.eq(#sql("\(new.primaryKey)")) |
| 88 | + && $0.recordType.eq(tableName) |
| 89 | + && $0._isDeleted |
| 90 | + } |
| 91 | + .update { |
| 92 | + $0._isDeleted = false |
| 93 | + $0.userModificationTime = $currentTime() |
| 94 | + } |
85 | 95 | } |
86 | 96 | ) |
87 | 97 | } |
|
242 | 252 | afterZoneUpdateTrigger(), |
243 | 253 | afterUpdateTrigger(for: syncEngine), |
244 | 254 | afterSoftDeleteTrigger(for: syncEngine), |
| 255 | + afterUndeleteTrigger(for: syncEngine), |
245 | 256 | ] |
246 | 257 | } |
247 | 258 |
|
|
348 | 359 | } |
349 | 360 | ) |
350 | 361 | } |
| 362 | + |
| 363 | + fileprivate static func afterUndeleteTrigger( |
| 364 | + for syncEngine: SyncEngine |
| 365 | + ) -> TemporaryTrigger<Self> { |
| 366 | + createTemporaryTrigger( |
| 367 | + "\(String.sqliteDataCloudKitSchemaName)_after_undelete_on_sqlitedata_icloud_metadata", |
| 368 | + ifNotExists: true, |
| 369 | + after: .update(of: \._isDeleted) { _, new in |
| 370 | + Values( |
| 371 | + syncEngine.$didUpdate( |
| 372 | + recordName: new.recordName, |
| 373 | + zoneName: new.zoneName, |
| 374 | + ownerName: new.ownerName, |
| 375 | + oldZoneName: new.zoneName, |
| 376 | + oldOwnerName: new.ownerName, |
| 377 | + descendantRecordNames: #bind(nil) |
| 378 | + ) |
| 379 | + ) |
| 380 | + } when: { old, new in |
| 381 | + old._isDeleted && !new._isDeleted && !SyncEngine.$isSynchronizing |
| 382 | + } |
| 383 | + ) |
| 384 | + } |
351 | 385 | } |
352 | 386 |
|
353 | 387 | @available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) |
|
0 commit comments