From 852a17e2283a41d071c347342b0e82874b316f65 Mon Sep 17 00:00:00 2001 From: wibus-wee <1596355173@qq.com> Date: Mon, 23 Oct 2023 22:54:45 +0800 Subject: [PATCH] Fix: Data errors caused by not updating in time after modifying the picture Metadata #4 --- PhotosProcessor/Backend/ProcessImage.swift | 9 +++++++++ PhotosProcessor/Views/Features/ModifyMetadataView.swift | 2 ++ 2 files changed, 11 insertions(+) diff --git a/PhotosProcessor/Backend/ProcessImage.swift b/PhotosProcessor/Backend/ProcessImage.swift index 18d8523..f5ffcd9 100644 --- a/PhotosProcessor/Backend/ProcessImage.swift +++ b/PhotosProcessor/Backend/ProcessImage.swift @@ -91,4 +91,13 @@ class ProcessImage: NSObject, ObservableObject { self.inited = true print("[I] Loaded image: \(self.url!)") } + + func refresh() { + if !self.inited { + print("[W] Image not inited. Refresh failed.") + return + } + print("[I] Refreshed image: \(self.url!)") + self.setup(url: self.url!) + } } diff --git a/PhotosProcessor/Views/Features/ModifyMetadataView.swift b/PhotosProcessor/Views/Features/ModifyMetadataView.swift index 94e8a20..0b7d20f 100644 --- a/PhotosProcessor/Views/Features/ModifyMetadataView.swift +++ b/PhotosProcessor/Views/Features/ModifyMetadataView.swift @@ -175,6 +175,7 @@ struct ModifyMetadataView: View { return } let _ = processImage.imageMetadata!.syncImageDate(path: processImage.imageMetadata!.url!.path) + processImage.refresh() } label: { Label("Sync DateTimeOriginal to CreateDate", systemImage: "arrow.clockwise") } @@ -222,6 +223,7 @@ struct ModifyMetadataView: View { print("[E] Bug occurred when edit metadata") InternalKit.eazyAlert(title: "Error", message: "Bug occurred when edit metadata") } + processImage.refresh() } label: { Label("Modify", systemImage: "hammer") }