From dac82323243868883a241251d9114cecc3d24d0e Mon Sep 17 00:00:00 2001 From: cdricms <36056008+cdricms@users.noreply.github.com> Date: Wed, 12 Aug 2026 11:34:49 +0200 Subject: [PATCH] fix(apple): realign UI layer with regenerated core bindings - map the new VnidropError cases (DeviceUnavailable, OfferTimeout, RelayPolicyIncompatible, ProtocolIncompatible) to existing catalog keys - drop the stale .map(\.share) now that sharePickedFiles returns Share - remove the duplicate .transfersChanged pattern in the signal switch - replace the deprecated String(cString:) sysctl decode - close the CoreGateway protocol declaration --- apple/VniDrop/Core/CoreGateway.swift | 1 + .../Notifications/TransferNotificationCoordinator.swift | 2 +- apple/VniDrop/Features/Send/SendModel.swift | 2 +- apple/VniDrop/Platform/AppDependencies+macOS.swift | 5 +++-- apple/VniDrop/UI/Feedback/UserFacingError.swift | 6 ++++++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apple/VniDrop/Core/CoreGateway.swift b/apple/VniDrop/Core/CoreGateway.swift index 5c57763..e7a5620 100644 --- a/apple/VniDrop/Core/CoreGateway.swift +++ b/apple/VniDrop/Core/CoreGateway.swift @@ -47,3 +47,4 @@ protocol CoreGateway: AnyObject { func receiverRequests(transferId: UInt64) async -> Result<[ReceiverRequestModel], Error> func respondReceiverRequest(requestId: String, accepted: Bool, reason: String?) async -> Result func refresh() async -> Result +} diff --git a/apple/VniDrop/Features/Notifications/TransferNotificationCoordinator.swift b/apple/VniDrop/Features/Notifications/TransferNotificationCoordinator.swift index 22e5b62..4c52fb7 100644 --- a/apple/VniDrop/Features/Notifications/TransferNotificationCoordinator.swift +++ b/apple/VniDrop/Features/Notifications/TransferNotificationCoordinator.swift @@ -111,7 +111,7 @@ final class TransferNotificationCoordinator: ObservableObject { switch signal { case .receiverHistoryChanged(let transferId), .transfersChanged(let transferId): Task { await self.syncReceivers(transferId: transferId) } - case .approvalChanged, .transfersChanged: + case .approvalChanged: break } } diff --git a/apple/VniDrop/Features/Send/SendModel.swift b/apple/VniDrop/Features/Send/SendModel.swift index 10400a3..ae1d4d8 100644 --- a/apple/VniDrop/Features/Send/SendModel.swift +++ b/apple/VniDrop/Features/Send/SendModel.swift @@ -353,7 +353,7 @@ final class SendModel: ObservableObject { senderName: current.senderName.trimmingCharacters(in: .whitespacesAndNewlines), destination: .invitation(accessPolicy: current.accessPolicy) ) - switch result.map(\.share) { + switch result { case .success(let share): await fileSystemService.discardPickedFiles(current.selectedFiles) if let thumb = current.selectedFiles.compactMap(\.thumbnailData).first { diff --git a/apple/VniDrop/Platform/AppDependencies+macOS.swift b/apple/VniDrop/Platform/AppDependencies+macOS.swift index ed7c14f..f227481 100644 --- a/apple/VniDrop/Platform/AppDependencies+macOS.swift +++ b/apple/VniDrop/Platform/AppDependencies+macOS.swift @@ -42,9 +42,10 @@ private struct MacDeviceInfoProvider: DeviceInfoProvider { var size = 0 sysctlbyname("hw.model", nil, &size, nil, 0) guard size > 0 else { return nil } - var model = [CChar](repeating: 0, count: size) + var model = [UInt8](repeating: 0, count: size) sysctlbyname("hw.model", &model, &size, nil, 0) - return String(cString: model) + // sysctl reports a NUL-terminated C string; drop the terminator(s). + return String(decoding: model.prefix(while: { $0 != 0 }), as: UTF8.self) } } #endif diff --git a/apple/VniDrop/UI/Feedback/UserFacingError.swift b/apple/VniDrop/UI/Feedback/UserFacingError.swift index 3784f94..f8bb041 100644 --- a/apple/VniDrop/UI/Feedback/UserFacingError.swift +++ b/apple/VniDrop/UI/Feedback/UserFacingError.swift @@ -30,6 +30,10 @@ extension Error { return .resource(L10n.Error.storageFull) case .Network: return .resource(L10n.Error.network) + case .DeviceUnavailable, .RelayPolicyIncompatible: + return .resource(L10n.Error.network) + case .OfferTimeout, .ProtocolIncompatible: + return .resource(L10n.Error.transfer) case .Transfer(let reason): return transferUiText(reason) case .Repository: @@ -88,6 +92,8 @@ extension Error { switch vni { case .Initialization(let r), .Ticket(let r), .Filesystem(let r), .FilesystemPermission(let r), .DestinationExists(let r), .StorageFull(let r), .Network(let r), + .DeviceUnavailable(let r), .OfferTimeout(let r), + .RelayPolicyIncompatible(let r), .ProtocolIncompatible(let r), .Transfer(let r), .Permission(let r), .Repository(let r), .Cancelled(let r), .InvalidInput(let r), .InvalidTransition(let r), .SecureStorageLocked(let r), .SecureStorageMissing(let r), .SecureStorageCorrupted(let r),