Implement post editor gallery image imports
This commit is contained in:
@@ -48,6 +48,31 @@ pub fn pick_media_files(title: String, filter_label: String) -> Task<Message> {
|
||||
)
|
||||
}
|
||||
|
||||
/// Pick images for a persisted post's batch gallery workflow.
|
||||
pub fn pick_gallery_images(post_id: String, title: String, filter_label: String) -> Task<Message> {
|
||||
Task::perform(
|
||||
async move {
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
std::panic::catch_unwind(|| {
|
||||
rfd::FileDialog::new()
|
||||
.set_title(&title)
|
||||
.add_filter(
|
||||
&filter_label,
|
||||
&["jpg", "jpeg", "png", "gif", "webp", "tiff", "bmp"],
|
||||
)
|
||||
.pick_files()
|
||||
})
|
||||
.map_err(|_| "native image picker failed".to_string())
|
||||
})
|
||||
.await
|
||||
.map_err(|error| error.to_string())
|
||||
.and_then(|result| result);
|
||||
(post_id, result)
|
||||
},
|
||||
|(post_id, result)| Message::GalleryImagesPicked { post_id, result },
|
||||
)
|
||||
}
|
||||
|
||||
/// Pick a replacement image for an existing media item.
|
||||
pub fn pick_media_replacement(
|
||||
media_id: String,
|
||||
|
||||
Reference in New Issue
Block a user