Attachment upload with file dialog#674
Attachment upload with file dialog#674alanpoon wants to merge 15 commits intoproject-robius:mainfrom
Conversation
|
awesome! I know this isn't yet complete, but I wanted to quickly drop in and suggest using Plus, with |
Kindly refer to this implementation of the rfd. https://github.com/Vjze/YY_DPS/blob/edb15ffc85b646c27547081b30a0e6f0d8ba688b/src/export/export_view.rs#L158 This requires the tokio runtime in a field in export screen |
Ok, what's the issue with that? Is that problematic? Apologies, but I'm not quite sure what point you're trying to make. Moly has used |
Thanks for referring me to Moly. File Dialog does not work well in asynchronously in macOS as file dialog is only allowing in main thread. |
eae0bfa to
f922cf2
Compare
src/sliding_sync.rs
Outdated
| // Upload the file to the media repository and send the message | ||
| let file_size_uint = UInt::try_from(file_meta.file_size).ok(); | ||
| let attachment_config = matrix_sdk::attachment::AttachmentConfig::new() | ||
| .info(if mime_type.type_() == mime::IMAGE { | ||
| matrix_sdk::attachment::AttachmentInfo::Image( | ||
| matrix_sdk::attachment::BaseImageInfo { | ||
| height: None, | ||
| width: None, | ||
| size: file_size_uint, | ||
| blurhash: None, | ||
| is_animated: None, | ||
| } | ||
| ) | ||
| } else { | ||
| matrix_sdk::attachment::AttachmentInfo::File( | ||
| matrix_sdk::attachment::BaseFileInfo { | ||
| size: file_size_uint, | ||
| } | ||
| ) | ||
| }); | ||
|
|
||
| // Note: Matrix SDK doesn't currently support progress tracking via observable | ||
| // The progress_sender is kept for future compatibility | ||
| let Some(progress_sender) = progress_sender else { | ||
| error!("Progress sender not provided for file upload to room {room_id}"); | ||
| return; | ||
| }; | ||
|
|
||
| progress_sender.set(TransmissionProgress { total: file_meta.file_size as usize, current: 0 }); | ||
|
|
||
| let result = room.send_attachment( | ||
| &file_meta.filename, | ||
| &mime_type, | ||
| file_data, | ||
| attachment_config, | ||
| ).with_send_progress_observable(progress_sender.clone()).store_in_cache().await; |
There was a problem hiding this comment.
you're doing a lot of stuff manually here, some of which (I think) the Timeline's functions already handle for you.
For example, there is Timeline::send_attachment() and Timeline::send_gallery(), and of course send() and send_reply() which we already use (and I see you have used here as well for replies).
I don't mind if we call the Room sending functions directly, but is there a particular reason to do so? I would expect it to be easier/simpler to use the TImeline-provided functions.
Can you explain your rationale / thought process here? perhaps there is a reason why we can't use the Timeline::send* functions?
There was a problem hiding this comment.
Sorry, I did not check the timeline api, lost touch.
kevinaboos
left a comment
There was a problem hiding this comment.
Thanks Alan, looks very good — impressive work here!
I left comments about a few major structural decisions, but it's mostly just about refactoring things into more modular widgets. I also left some questions about using higher-level Timeline APIs vs Room APIs for sending attachments.
src/room/room_input_bar.rs
Outdated
| /// Maximum file size allowed for upload (100 MB). | ||
| /// Files larger than this will be rejected to prevent memory issues. | ||
| const MAX_FILE_SIZE_BYTES: u64 = 100 * 1024 * 1024; |
There was a problem hiding this comment.
no need for artificial limits. The homeserver should be responsible for informing us when a file is too large.
While the main matrix.org homeserver typically uses 100MB limits, other private homeservers likely do not have those limits.
src/room/room_input_bar.rs
Outdated
|
|
||
| // Handle the file attachment upload button being clicked. | ||
| if self.button(ids!(attachment_upload_button)).clicked(actions) { | ||
| if !cx.display_context.is_desktop() { |
There was a problem hiding this comment.
"is_desktop()" is confusingly named here, it just checks for the window size, not the actual platform.
Instead, you should check the built-in target_os like we do for all robius crates; that way you can correctly and explicitly exclude ios and android.
There was a problem hiding this comment.
Changed to target_os.
Also, now that you're using |
Screen.Recording.2026-01-26.at.4.09.11.PM.mov