Prevent saving when some file properties change
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user