Skip to main content

Pick up edits to photos made outside the app

ID
1352565
date
2023-06-18 16:59:46+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
d55716d
message
Pick up edits to photos made outside the app
changed files
3 files, 19 additions, 6 deletions

Changed files

BlinkReviewer/Blink.xcodeproj/project.pbxproj (35247) → BlinkReviewer/Blink.xcodeproj/project.pbxproj (35247)

diff --git a/BlinkReviewer/Blink.xcodeproj/project.pbxproj b/BlinkReviewer/Blink.xcodeproj/project.pbxproj
index 1116e55..05eef65 100644
--- a/BlinkReviewer/Blink.xcodeproj/project.pbxproj
+++ b/BlinkReviewer/Blink.xcodeproj/project.pbxproj
@@ -604,7 +604,7 @@
 				CODE_SIGN_ENTITLEMENTS = Blink/Blink.entitlements;
 				CODE_SIGN_STYLE = Automatic;
 				COMBINE_HIDPI_IMAGES = YES;
-				CURRENT_PROJECT_VERSION = 89;
+				CURRENT_PROJECT_VERSION = 92;
 				DEVELOPMENT_ASSET_PATHS = "\"Blink/Preview Content\"";
 				ENABLE_HARDENED_RUNTIME = YES;
 				ENABLE_PREVIEWS = YES;
@@ -632,7 +632,7 @@
 				CODE_SIGN_ENTITLEMENTS = Blink/Blink.entitlements;
 				CODE_SIGN_STYLE = Automatic;
 				COMBINE_HIDPI_IMAGES = YES;
-				CURRENT_PROJECT_VERSION = 89;
+				CURRENT_PROJECT_VERSION = 92;
 				DEVELOPMENT_ASSET_PATHS = "\"Blink/Preview Content\"";
 				ENABLE_HARDENED_RUNTIME = YES;
 				ENABLE_PREVIEWS = YES;
@@ -658,7 +658,7 @@
 				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				BUNDLE_LOADER = "$(TEST_HOST)";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 89;
+				CURRENT_PROJECT_VERSION = 92;
 				GENERATE_INFOPLIST_FILE = YES;
 				MACOSX_DEPLOYMENT_TARGET = 13.3;
 				MARKETING_VERSION = 1.0;
@@ -676,7 +676,7 @@
 				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				BUNDLE_LOADER = "$(TEST_HOST)";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 89;
+				CURRENT_PROJECT_VERSION = 92;
 				GENERATE_INFOPLIST_FILE = YES;
 				MACOSX_DEPLOYMENT_TARGET = 13.3;
 				MARKETING_VERSION = 1.0;
@@ -693,7 +693,7 @@
 			buildSettings = {
 				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 89;
+				CURRENT_PROJECT_VERSION = 92;
 				GENERATE_INFOPLIST_FILE = YES;
 				MARKETING_VERSION = 1.0;
 				PRODUCT_BUNDLE_IDENTIFIER = net.alexwlchan.BlinkReviewerUITests;
@@ -709,7 +709,7 @@
 			buildSettings = {
 				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 89;
+				CURRENT_PROJECT_VERSION = 92;
 				GENERATE_INFOPLIST_FILE = YES;
 				MARKETING_VERSION = 1.0;
 				PRODUCT_BUNDLE_IDENTIFIER = net.alexwlchan.BlinkReviewerUITests;

BlinkReviewer/Blink/Model/LRUCache.swift (1255) → BlinkReviewer/Blink/Model/LRUCache.swift (1388)

diff --git a/BlinkReviewer/Blink/Model/LRUCache.swift b/BlinkReviewer/Blink/Model/LRUCache.swift
index 36007e6..211c596 100644
--- a/BlinkReviewer/Blink/Model/LRUCache.swift
+++ b/BlinkReviewer/Blink/Model/LRUCache.swift
@@ -40,4 +40,9 @@ struct LRUCache<Key: Hashable, Value> {
             }
         }
     }
+    
+    mutating func removeValue(forKey key: Key) {
+        keyHistory.remove(key)
+        contents.removeValue(forKey: key)
+    }
 }

BlinkReviewer/Blink/Photos/PhotosLibrary.swift (16753) → BlinkReviewer/Blink/Photos/PhotosLibrary.swift (17214)

diff --git a/BlinkReviewer/Blink/Photos/PhotosLibrary.swift b/BlinkReviewer/Blink/Photos/PhotosLibrary.swift
index 9eda73d..0e5fd35 100644
--- a/BlinkReviewer/Blink/Photos/PhotosLibrary.swift
+++ b/BlinkReviewer/Blink/Photos/PhotosLibrary.swift
@@ -140,6 +140,14 @@ class PhotosLibrary: NSObject, ObservableObject, PHPhotoLibraryChangeObserver {
                 self.assets = assetsChangeDetails.fetchResultAfterChanges
                 
                 assetsChangeDetails.changedObjects.forEach { asset in
+                    // Flush the cached thumbnail/full-sized image for the asset; the
+                    // external edit may have been modifying the image.
+                    //
+                    // TODO: This only updates the full-size image in Blink, not the
+                    // thumbnail.  What's up with that?
+                    self.thumbnailCache.removeValue(forKey: asset)
+                    self.fullSizeImageCache.removeValue(forKey: asset)
+
                     if asset.isFavorite {
                         self.favoriteAssetIdentifiers.insert(asset.localIdentifier)
                     } else {