@@ -22,7 +22,7 @@ use matrix_sdk::room::reply::{EnforceThread, Reply};
2222use ruma:: events:: room:: message:: AddMentions ;
2323use matrix_sdk_ui:: timeline:: { EmbeddedEvent , EventTimelineItem , TimelineEventItemId } ;
2424use ruma:: { events:: room:: message:: { LocationMessageEventContent , MessageType , ReplyWithinThread , RoomMessageEventContent } , OwnedEventId , OwnedRoomId } ;
25- use crate :: { home:: { editing_pane:: { EditingPaneState , EditingPaneWidgetExt , EditingPaneWidgetRefExt } , location_preview:: { LocationPreviewWidgetExt , LocationPreviewWidgetRefExt } , room_screen:: { MessageAction , RoomScreenProps , populate_preview_of_timeline_item} , tombstone_footer:: { SuccessorRoomDetails , TombstoneFooterWidgetExt } , upload_progress:: UploadProgressViewWidgetRefExt } , location:: init_location_subscriber, settings:: app_preferences:: { AppPreferencesAction , AppPreferencesGlobal } , shared:: { avatar:: AvatarWidgetRefExt , file_upload_modal:: { AttachmentUpload , FilePreviewerAction , FileUploadAttemptId , load_selected_file } , html_or_plaintext:: HtmlOrPlaintextWidgetRefExt , mentionable_text_input:: MentionableTextInputWidgetExt , popup_list:: { PopupKind , enqueue_popup_notification} , room_input_popup_menu:: RoomInputPopupMenuAction , styles:: * } , sliding_sync:: { MatrixRequest , TimelineKind , UserPowerLevels , submit_async_request} , utils} ;
25+ use crate :: { home:: { editing_pane:: { EditingPaneState , EditingPaneWidgetExt , EditingPaneWidgetRefExt } , location_preview:: { LocationPreviewWidgetExt , LocationPreviewWidgetRefExt } , room_screen:: { MessageAction , RoomScreenProps , populate_preview_of_timeline_item} , tombstone_footer:: { SuccessorRoomDetails , TombstoneFooterWidgetExt } , upload_progress:: UploadProgressViewWidgetRefExt } , location:: init_location_subscriber, settings:: app_preferences:: { AppPreferencesAction , AppPreferencesGlobal } , shared:: { avatar:: AvatarWidgetRefExt , file_upload_modal:: { AttachmentUpload , FileUploadModalAction , FileUploadAttemptId , PreviewPayload , load_file_metadata } , html_or_plaintext:: HtmlOrPlaintextWidgetRefExt , mentionable_text_input:: MentionableTextInputWidgetExt , popup_list:: { PopupKind , enqueue_popup_notification} , room_input_popup_menu:: RoomInputPopupMenuAction , styles:: * } , sliding_sync:: { MatrixRequest , TimelineKind , UserPowerLevels , submit_async_request} , utils} ;
2626
2727script_mod ! {
2828 use mod . prelude. widgets. *
@@ -694,15 +694,23 @@ impl RoomInputBar {
694694 match result {
695695 Ok ( Some ( picked) ) => match picked. into_local_file ( ) {
696696 Ok ( local_file) => {
697- let loaded = load_selected_file (
697+ match load_file_metadata (
698698 local_file,
699699 timeline_kind,
700700 in_reply_to,
701701 #[ cfg( feature = "tsp" ) ]
702702 sign_with_tsp,
703- ) ;
704- match loaded {
705- Ok ( upload) => Cx :: post_action ( FilePreviewerAction :: Show { upload } ) ,
703+ ) {
704+ Ok ( ( upload, preview_source, preview_id) ) => {
705+ // Show the preview modal instantly, and then re-use this bg thread
706+ // to read the file and generate the preview.
707+ Cx :: post_action ( FileUploadModalAction :: Show { upload, preview_id } ) ;
708+ let preview = preview_source. build ( ) ;
709+ Cx :: post_action ( FileUploadModalAction :: PreviewReady {
710+ preview_id,
711+ preview : PreviewPayload :: new ( preview) ,
712+ } ) ;
713+ }
706714 Err ( e) => enqueue_popup_notification ( e, PopupKind :: Error , None ) ,
707715 }
708716 }
0 commit comments