Prevent saving when some file properties change

This commit is contained in:
Christoph Hagen
2025-05-04 08:57:16 +02:00
parent 4f31622abe
commit 062e7d289a
4 changed files with 63 additions and 17 deletions

View File

@@ -47,6 +47,9 @@ final class Content: ObservableObject {
var errorCallback: ((StorageError) -> Void)?
/// A cache of file sizes
private var fileSizes: [String: Int] = [:]
init() {
let settings = Settings.default
self.settings = settings
@@ -196,4 +199,26 @@ final class Content: ObservableObject {
func setLastSaveTimestamp() {
self.lastSave = .now
}
// MARK: File sizes
func size(of file: String) -> Int? {
fileSizes[file]
}
func cache(size: Int?, of file: String) {
fileSizes[file] = size
}
// MARK: Image dimensions
private var imageDimensions: [String: CGSize] = [:]
func dimensions(of image: String) -> CGSize? {
imageDimensions[image]
}
func cache(dimensions: CGSize?, of image: String) {
imageDimensions[image] = dimensions
}
}