File tree Expand file tree Collapse file tree 1 file changed +24
-8
lines changed
crates/matrix-sdk/src/room Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -687,12 +687,26 @@ impl Joined {
687
687
#[ cfg( feature = "image-proc" ) ]
688
688
let data_slot;
689
689
#[ cfg( feature = "image-proc" ) ]
690
- let thumbnail = if config. generate_thumbnail {
691
- match generate_image_thumbnail (
692
- content_type,
693
- Cursor :: new ( & data) ,
694
- config. thumbnail_size ,
695
- ) {
690
+ let ( data, thumbnail) = if config. generate_thumbnail {
691
+ let content_type = content_type. clone ( ) ;
692
+ let make_thumbnail = move |data| {
693
+ let res = generate_image_thumbnail (
694
+ & content_type,
695
+ Cursor :: new ( & data) ,
696
+ config. thumbnail_size ,
697
+ ) ;
698
+ ( data, res)
699
+ } ;
700
+
701
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
702
+ let ( data, res) = tokio:: task:: spawn_blocking ( move || make_thumbnail ( data) )
703
+ . await
704
+ . expect ( "Task join error" ) ;
705
+
706
+ #[ cfg( target_arch = "wasm32" ) ]
707
+ let ( data, res) = make_thumbnail ( data) ;
708
+
709
+ let thumbnail = match res {
696
710
Ok ( ( thumbnail_data, thumbnail_info) ) => {
697
711
data_slot = thumbnail_data;
698
712
Some ( Thumbnail {
@@ -705,9 +719,11 @@ impl Joined {
705
719
ImageError :: ThumbnailBiggerThanOriginal | ImageError :: FormatNotSupported ,
706
720
) => None ,
707
721
Err ( error) => return Err ( error. into ( ) ) ,
708
- }
722
+ } ;
723
+
724
+ ( data, thumbnail)
709
725
} else {
710
- None
726
+ ( data , None )
711
727
} ;
712
728
713
729
let config = AttachmentConfig {
You can’t perform that action at this time.
0 commit comments