Implement post editor gallery image imports

This commit is contained in:
2026-07-19 09:52:09 +02:00
parent 9a72287fc6
commit 055dd5efc5
17 changed files with 949 additions and 82 deletions

View File

@@ -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,