From 4c0e1ff5f82a06513295b1e4287c420ebd69ae90 Mon Sep 17 00:00:00 2001 From: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Date: Sun, 12 Oct 2025 17:21:25 +0530 Subject: [PATCH] review changes --- mobile/ios/Runner/AppDelegate.swift | 4 +--- mobile/ios/Runner/Sync/MessagesImpl.swift | 14 +++++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/mobile/ios/Runner/AppDelegate.swift b/mobile/ios/Runner/AppDelegate.swift index 9f3ae1cfe6..ce24dc6bbc 100644 --- a/mobile/ios/Runner/AppDelegate.swift +++ b/mobile/ios/Runner/AppDelegate.swift @@ -52,9 +52,7 @@ import UIKit } public static func registerPlugins(with engine: FlutterEngine) { - if !engine.hasPlugin("NativeSyncApi") { - NativeSyncApiImpl.register(with: engine.registrar(forPlugin: "NativeSyncApi")!) - } + NativeSyncApiImpl.register(with: engine.registrar(forPlugin: NativeSyncApiImpl.name)!) ThumbnailApiSetup.setUp(binaryMessenger: engine.binaryMessenger, api: ThumbnailApiImpl()) BackgroundWorkerFgHostApiSetup.setUp(binaryMessenger: engine.binaryMessenger, api: BackgroundWorkerApiImpl()) } diff --git a/mobile/ios/Runner/Sync/MessagesImpl.swift b/mobile/ios/Runner/Sync/MessagesImpl.swift index 2305be3cca..0e6ef9f403 100644 --- a/mobile/ios/Runner/Sync/MessagesImpl.swift +++ b/mobile/ios/Runner/Sync/MessagesImpl.swift @@ -33,7 +33,7 @@ class NativeSyncApiImpl: ImmichPlugin, NativeSyncApi, FlutterPlugin { private let albumTypes: [PHAssetCollectionType] = [.album, .smartAlbum] private let recoveredAlbumSubType = 1000000219 - private var hashTask: Task? + private var hashTask: Task? private static let hashCancelledCode = "HASH_CANCELLED" private static let hashCancelled = Result<[HashResult], Error>.failure(PigeonError(code: hashCancelledCode, message: "Hashing cancelled", details: nil)) @@ -282,8 +282,7 @@ class NativeSyncApiImpl: ImmichPlugin, NativeSyncApi, FlutterPlugin { } if Task.isCancelled { - self?.completeWhenActive(for: completion, with: Self.hashCancelled) - return + return self?.completeWhenActive(for: completion, with: Self.hashCancelled) } await withTaskGroup(of: HashResult?.self) { taskGroup in @@ -291,8 +290,7 @@ class NativeSyncApiImpl: ImmichPlugin, NativeSyncApi, FlutterPlugin { results.reserveCapacity(assets.count) for asset in assets { if Task.isCancelled { - self?.completeWhenActive(for: completion, with: Self.hashCancelled) - return + return self?.completeWhenActive(for: completion, with: Self.hashCancelled) } taskGroup.addTask { guard let self = self else { return nil } @@ -302,8 +300,7 @@ class NativeSyncApiImpl: ImmichPlugin, NativeSyncApi, FlutterPlugin { for await result in taskGroup { guard let result = result else { - self?.completeWhenActive(for: completion, with: Self.hashCancelled) - return + return self?.completeWhenActive(for: completion, with: Self.hashCancelled) } results.append(result) } @@ -312,8 +309,7 @@ class NativeSyncApiImpl: ImmichPlugin, NativeSyncApi, FlutterPlugin { results.append(HashResult(assetId: missing, error: "Asset not found in library", hash: nil)) } - self?.completeWhenActive(for: completion, with: .success(results)) - return + return self?.completeWhenActive(for: completion, with: .success(results)) } } }