Fix potentially buggy media uploader setting

This commit is contained in:
William Casarin
2023-04-22 12:11:31 -07:00
parent 055b13c1cd
commit f14ba7cce4
4 changed files with 13 additions and 10 deletions

View File

@@ -8,7 +8,7 @@
import SwiftUI
struct EditProfilePictureControl: View {
let uploader: MediaUploader
let pubkey: String
@Binding var profile_image: URL?
@ObservedObject var viewModel: ProfileUploadingViewModel
@@ -46,7 +46,7 @@ struct EditProfilePictureControl: View {
}
.sheet(isPresented: $show_camera) {
// The alert may not be required for the profile pic upload case. Not showing the confirm check alert for this scenario
ImagePicker(sourceType: .camera, pubkey: pubkey, image_upload_confirm: $image_upload_confirm, imagesOnly: true) { img in
ImagePicker(uploader: uploader, sourceType: .camera, pubkey: pubkey, image_upload_confirm: $image_upload_confirm, imagesOnly: true) { img in
handle_upload(media: .image(img))
} onVideoPicked: { url in
print("Cannot upload videos as profile image")
@@ -54,7 +54,7 @@ struct EditProfilePictureControl: View {
}
.sheet(isPresented: $show_library) {
// The alert may not be required for the profile pic upload case. Not showing the confirm check alert for this scenario
ImagePicker(sourceType: .photoLibrary, pubkey: pubkey, image_upload_confirm: $image_upload_confirm, imagesOnly: true) { img in
ImagePicker(uploader: uploader, sourceType: .photoLibrary, pubkey: pubkey, image_upload_confirm: $image_upload_confirm, imagesOnly: true) { img in
handle_upload(media: .image(img))
} onVideoPicked: { url in
print("Cannot upload videos as profile image")
@@ -64,7 +64,6 @@ struct EditProfilePictureControl: View {
private func handle_upload(media: MediaUpload) {
viewModel.isLoading = true
let uploader = get_media_uploader(pubkey)
Task {
let res = await image_upload.start(media: media, uploader: uploader)

View File

@@ -23,11 +23,15 @@ struct ProfilePictureSelector: View {
@State var profile_image: URL? = nil
var uploader: MediaUploader {
damus_state?.settings.default_media_uploader ?? .nostrBuild
}
var body: some View {
let highlight: Highlight = .custom(Color.white, 2.0)
ZStack {
EditProfilePictureView(url: $profile_image, pubkey: pubkey, size: size, highlight: highlight, damus_state: damus_state)
EditProfilePictureControl(pubkey: pubkey, profile_image: $profile_image, viewModel: viewModel, callback: callback)
EditProfilePictureControl(uploader: uploader, pubkey: pubkey, profile_image: $profile_image, viewModel: viewModel, callback: callback)
}
}
}