Fix id of Items, saving

This commit is contained in:
Christoph Hagen
2025-06-11 08:19:44 +02:00
parent 5970ce2e9f
commit 1d0eba9d78
64 changed files with 233 additions and 217 deletions

View File

@@ -2,7 +2,7 @@ import Foundation
import SwiftUI
import Combine
final class Content: ObservableObject {
final class Content: ChangeObservableItem {
@ObservedObject
var storage: Storage
@@ -47,6 +47,8 @@ final class Content: ObservableObject {
var errorCallback: ((StorageError) -> Void)?
var cancellables: Set<AnyCancellable> = []
/// A cache of file sizes
private var fileSizes: [String: Int] = [:]
@@ -200,9 +202,9 @@ final class Content: ObservableObject {
for file in self.files {
guard file.type.isVideo else { continue }
guard !file.isExternallyStored else { continue }
guard !storage.hasVideoThumbnail(for: file.id) else { continue }
if await imageGenerator.createVideoThumbnail(for: file.id) {
print("Generated thumbnail for \(file.id)")
guard !storage.hasVideoThumbnail(for: file.identifier) else { continue }
if await imageGenerator.createVideoThumbnail(for: file.identifier) {
print("Generated thumbnail for \(file.identifier)")
file.didChange()
}
}
@@ -229,6 +231,10 @@ final class Content: ObservableObject {
self.lastSave = .now
}
func needsSaving() {
needsSave()
}
// MARK: File sizes
func size(of file: String) -> Int? {