trailing closures in swift

This commit is contained in:
shenlong-tanwen
2025-09-29 03:38:29 +05:30
parent 13abe14142
commit 0e8492ceba
2 changed files with 9 additions and 9 deletions
@@ -2,11 +2,11 @@ import BackgroundTasks
class BackgroundWorkerApiImpl: BackgroundWorkerFgHostApi { class BackgroundWorkerApiImpl: BackgroundWorkerFgHostApi {
func enable(completion: @escaping (Result<Void, any Error>) -> Void) { func enable(completion: @escaping (Result<Void, any Error>) -> Void) {
dispatch(completion: completion, block: { dispatch(completion: completion) {
BackgroundWorkerApiImpl.scheduleRefreshWorker() BackgroundWorkerApiImpl.scheduleRefreshWorker()
BackgroundWorkerApiImpl.scheduleProcessingWorker() BackgroundWorkerApiImpl.scheduleProcessingWorker()
print("BackgroundWorkerApiImpl:enable Background worker scheduled") print("BackgroundWorkerApiImpl:enable Background worker scheduled")
}); }
} }
func configure(settings: BackgroundWorkerSettings, completion: @escaping (Result<Void, any Error>) -> Void) { func configure(settings: BackgroundWorkerSettings, completion: @escaping (Result<Void, any Error>) -> Void) {
@@ -15,11 +15,11 @@ class BackgroundWorkerApiImpl: BackgroundWorkerFgHostApi {
} }
func disable(completion: @escaping (Result<Void, any Error>) -> Void) { func disable(completion: @escaping (Result<Void, any Error>) -> Void) {
dispatch(completion: completion, block: { dispatch(completion: completion) {
BGTaskScheduler.shared.cancel(taskRequestWithIdentifier: BackgroundWorkerApiImpl.refreshTaskID); BGTaskScheduler.shared.cancel(taskRequestWithIdentifier: BackgroundWorkerApiImpl.refreshTaskID);
BGTaskScheduler.shared.cancel(taskRequestWithIdentifier: BackgroundWorkerApiImpl.processingTaskID); BGTaskScheduler.shared.cancel(taskRequestWithIdentifier: BackgroundWorkerApiImpl.processingTaskID);
print("BackgroundWorkerApiImpl:disableUploadWorker Disabled background workers") print("BackgroundWorkerApiImpl:disableUploadWorker Disabled background workers")
}); }
} }
private static let refreshTaskID = "app.alextran.immich.background.refreshUpload" private static let refreshTaskID = "app.alextran.immich.background.refreshUpload"
+5 -5
View File
@@ -209,7 +209,7 @@ class NativeSyncApiImpl: NativeSyncApi {
} }
func getAssetIdsForAlbum(albumId: String, completion: @escaping (Result<[String], any Error>) -> Void) { func getAssetIdsForAlbum(albumId: String, completion: @escaping (Result<[String], any Error>) -> Void) {
dispatch(qos: .userInitiated, completion: completion, block: { try self.getAssetIdsForAlbum(albumId: albumId) }) dispatch(qos: .userInitiated, completion: completion) { try self.getAssetIdsForAlbum(albumId: albumId) }
} }
private func getAssetIdsForAlbum(albumId: String) throws -> [String] { private func getAssetIdsForAlbum(albumId: String) throws -> [String] {
@@ -229,9 +229,9 @@ class NativeSyncApiImpl: NativeSyncApi {
} }
func getAssetsCountSince(albumId: String, timestamp: Int64, completion: @escaping (Result<Int64, any Error>) -> Void) { func getAssetsCountSince(albumId: String, timestamp: Int64, completion: @escaping (Result<Int64, any Error>) -> Void) {
dispatch(qos: .userInitiated, completion: completion, block: { dispatch(qos: .userInitiated, completion: completion) {
try self.getAssetsCountSince(albumId: albumId, timestamp: timestamp) try self.getAssetsCountSince(albumId: albumId, timestamp: timestamp)
}) }
} }
private func getAssetsCountSince(albumId: String, timestamp: Int64) throws -> Int64 { private func getAssetsCountSince(albumId: String, timestamp: Int64) throws -> Int64 {
@@ -249,9 +249,9 @@ class NativeSyncApiImpl: NativeSyncApi {
} }
func getAssetsForAlbum(albumId: String, updatedTimeCond: Int64?, completion: @escaping (Result<[PlatformAsset], any Error>) -> Void) { func getAssetsForAlbum(albumId: String, updatedTimeCond: Int64?, completion: @escaping (Result<[PlatformAsset], any Error>) -> Void) {
dispatch(qos: .userInitiated, completion: completion, block: { dispatch(qos: .userInitiated, completion: completion) {
try self.getAssetsForAlbum(albumId: albumId, updatedTimeCond: updatedTimeCond) try self.getAssetsForAlbum(albumId: albumId, updatedTimeCond: updatedTimeCond)
}) }
} }
private func getAssetsForAlbum(albumId: String, updatedTimeCond: Int64?) throws -> [PlatformAsset] { private func getAssetsForAlbum(albumId: String, updatedTimeCond: Int64?) throws -> [PlatformAsset] {