Update OTG transfer workflow
This commit is contained in:
@ -18,7 +18,7 @@ enum TravelAlbumCameraImportState: Equatable {
|
||||
case loading
|
||||
case loaded(sections: [TravelAlbumCameraImportSection])
|
||||
case importing(current: Int, total: Int)
|
||||
case finished(importedCount: Int, failedCount: Int)
|
||||
case finished(importedCount: Int, failedCount: Int, importedPhotoIds: [String])
|
||||
case failed(message: String)
|
||||
}
|
||||
|
||||
@ -180,6 +180,7 @@ final class TravelAlbumCameraImportViewModel {
|
||||
Task {
|
||||
let directory = try? storage.originalsDirectory(albumId: albumId)
|
||||
var importedCount = 0
|
||||
var importedPhotoIds: [String] = []
|
||||
|
||||
for (index, object) in selected.enumerated() {
|
||||
defer { state = .importing(current: index + 1, total: selected.count) }
|
||||
@ -204,6 +205,7 @@ final class TravelAlbumCameraImportViewModel {
|
||||
)
|
||||
storage.upsert(record, albumId: albumId)
|
||||
existingPhotoIds.insert(object.id)
|
||||
importedPhotoIds.append(record.id)
|
||||
importedCount += 1
|
||||
} catch {
|
||||
failedPhotoIds.insert(object.id)
|
||||
@ -212,7 +214,11 @@ final class TravelAlbumCameraImportViewModel {
|
||||
}
|
||||
|
||||
selectedPhotoIds.subtract(existingPhotoIds)
|
||||
state = .finished(importedCount: importedCount, failedCount: failedPhotoIds.count)
|
||||
state = .finished(
|
||||
importedCount: importedCount,
|
||||
failedCount: failedPhotoIds.count,
|
||||
importedPhotoIds: importedPhotoIds
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user