diff --git a/damus.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/damus.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 000000000..755124dcf --- /dev/null +++ b/damus.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,58 @@ +{ + "originHash" : "0c5ba17ae4238ee8c0614e8f0957f83778e450906dcaf8ccca5c1aa44c24a252", + "pins" : [ + { + "identity" : "gsplayer", + "kind" : "remoteSourceControl", + "location" : "https://github.com/wxxsw/GSPlayer", + "state" : { + "revision" : "aa6dad7943d52f5207f7fcc2ad3e4274583443b8", + "version" : "0.2.26" + } + }, + { + "identity" : "kingfisher", + "kind" : "remoteSourceControl", + "location" : "https://github.com/onevcat/Kingfisher", + "state" : { + "revision" : "415b1d97fb38bda1e5a6b2dde63354720832110b", + "version" : "7.6.1" + } + }, + { + "identity" : "secp256k1.swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/jb55/secp256k1.swift", + "state" : { + "revision" : "40b4b38b3b1c83f7088c76189a742870e0ca06a9" + } + }, + { + "identity" : "swift-markdown-ui", + "kind" : "remoteSourceControl", + "location" : "https://github.com/damus-io/swift-markdown-ui", + "state" : { + "revision" : "76bb7971da7fbf429de1c84f1244adf657242fee" + } + }, + { + "identity" : "swift-snapshot-testing", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-snapshot-testing", + "state" : { + "revision" : "5b356adceabff6ca027f6574aac79e9fee145d26", + "version" : "1.14.1" + } + }, + { + "identity" : "swift-syntax", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-syntax.git", + "state" : { + "revision" : "74203046135342e4a4a627476dd6caf8b28fe11b", + "version" : "509.0.0" + } + } + ], + "version" : 3 +} diff --git a/damus.xcodeproj/xcshareddata/xcschemes/DamusNotificationService.xcscheme b/damus.xcodeproj/xcshareddata/xcschemes/DamusNotificationService.xcscheme index d2f574995..4c06fd6b8 100644 --- a/damus.xcodeproj/xcshareddata/xcschemes/DamusNotificationService.xcscheme +++ b/damus.xcodeproj/xcshareddata/xcschemes/DamusNotificationService.xcscheme @@ -77,6 +77,7 @@ savedToolIdentifier = "" useCustomWorkingDirectory = "NO" debugDocumentVersioning = "YES" + askForAppToLaunch = "Yes" launchAutomaticallySubstyle = "2"> diff --git a/damus/Models/ImageUploadModel.swift b/damus/Models/ImageUploadModel.swift index 7e556a683..0d4cdedaa 100644 --- a/damus/Models/ImageUploadModel.swift +++ b/damus/Models/ImageUploadModel.swift @@ -53,12 +53,15 @@ enum MediaUpload { class ImageUploadModel: NSObject, URLSessionTaskDelegate, ObservableObject { @Published var progress: Double? = nil + @Published var currentImagesUploaded: Int = 0 + @Published var totalImagesToUpload: Int = 0 + private var completedUploads: Int = 0 func start(media: MediaUpload, uploader: MediaUploader, keypair: Keypair? = nil) async -> ImageUploadResult { - let res = await create_upload_request(mediaToUpload: media, mediaUploader: uploader, progress: self, keypair: keypair) DispatchQueue.main.async { - self.progress = nil + self.totalImagesToUpload += 1 } + let res = await create_upload_request(mediaToUpload: media, mediaUploader: uploader, progress: self, keypair: keypair) return res } @@ -67,4 +70,20 @@ class ImageUploadModel: NSObject, URLSessionTaskDelegate, ObservableObject { self.progress = Double(totalBytesSent) / Double(totalBytesExpectedToSend) } } + + func didFinishUpload() { + DispatchQueue.main.async { + self.completedUploads += 1 + self.currentImagesUploaded = self.completedUploads + } + } + + func resetProgress() { + DispatchQueue.main.async { + self.progress = nil + self.currentImagesUploaded = 0 + self.totalImagesToUpload = 0 + self.completedUploads = 0 + } + } } diff --git a/damus/Views/PostView.swift b/damus/Views/PostView.swift index 7450dd5a5..86d465881 100644 --- a/damus/Views/PostView.swift +++ b/damus/Views/PostView.swift @@ -285,8 +285,11 @@ struct PostView: View { } if let progress = image_upload.progress { - ProgressView(value: progress, total: 1.0) - .progressViewStyle(.linear) + HStack { + ProgressView(value: progress, total: 1.0) + .progressViewStyle(.linear) + Text("\(image_upload.currentImagesUploaded)/\(image_upload.totalImagesToUpload)") + } } Divider() @@ -316,6 +319,7 @@ struct PostView: View { let meta = blurhash.map { bh in calculate_image_metadata(url: url, img: img, blurhash: bh) } let uploadedMedia = UploadedMedia(localURL: media.localURL, uploadedURL: url, representingImage: img, metadata: meta) uploadedMedias.append(uploadedMedia) + image_upload.didFinishUpload() case .failed(let error): if let error { @@ -325,6 +329,9 @@ struct PostView: View { } } + if (image_upload.currentImagesUploaded + 1) == image_upload.totalImagesToUpload { + image_upload.resetProgress() + } } }