From 49899ccb2cbe54e584ec2fdfef95bb7dae103192 Mon Sep 17 00:00:00 2001 From: Taufi Date: Thu, 14 Nov 2024 18:12:13 +0100 Subject: [PATCH] Improved PR following reviewer recommendations --- IceCubesApp.xcodeproj/project.pbxproj | 4 ++-- .../MediaUI/Sources/MediaUI/MediaUIView.swift | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/IceCubesApp.xcodeproj/project.pbxproj b/IceCubesApp.xcodeproj/project.pbxproj index 2764c57b..8d44e975 100644 --- a/IceCubesApp.xcodeproj/project.pbxproj +++ b/IceCubesApp.xcodeproj/project.pbxproj @@ -1545,7 +1545,7 @@ INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking"; INFOPLIST_KEY_NSCameraUsageDescription = "Upload photos & videos to attach to your Mastodon posts."; INFOPLIST_KEY_NSHumanReadableCopyright = "© 2024 Thomas Ricouard"; - INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = ""; + INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "Ice Cubes would like to save the selected photo in your photo library."; INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "Upload photos & videos to Mastodon"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; @@ -1612,7 +1612,7 @@ INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking"; INFOPLIST_KEY_NSCameraUsageDescription = "Upload photos & videos to attach to your Mastodon posts."; INFOPLIST_KEY_NSHumanReadableCopyright = "© 2024 Thomas Ricouard"; - INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = ""; + INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "Ice Cubes would like to save the selected photo in your photo library."; INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "Upload photos & videos to Mastodon"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; diff --git a/Packages/MediaUI/Sources/MediaUI/MediaUIView.swift b/Packages/MediaUI/Sources/MediaUI/MediaUIView.swift index 54e75ba8..0023d4a8 100644 --- a/Packages/MediaUI/Sources/MediaUI/MediaUIView.swift +++ b/Packages/MediaUI/Sources/MediaUI/MediaUIView.swift @@ -185,17 +185,17 @@ private struct SavePhotoToolbarItem: ToolbarContent, @unchecked Sendable { } private func saveImage(url: URL) async -> Bool { + guard let image = try? await uiimageFor(url: url) else { return false } + var status = PHPhotoLibrary.authorizationStatus(for: .addOnly) - if let image = try? await uiimageFor(url: url) { - if status != .authorized { - await PHPhotoLibrary.requestAuthorization(for: .addOnly) - status = PHPhotoLibrary.authorizationStatus(for: .addOnly) - } - if status == .authorized { - UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil) - return true - } + if status != .authorized { + await PHPhotoLibrary.requestAuthorization(for: .addOnly) + status = PHPhotoLibrary.authorizationStatus(for: .addOnly) + } + if status == .authorized { + UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil) + return true } return false }