[fractal] GUI: Check the start of the MIME string instead of doing single checks of the whole string



commit e384608e29ca6b1de993fc1145367347832e80d3
Author: Alejandro Domínguez <adomu net-c com>
Date:   Thu Apr 2 09:36:15 2020 +0200

    GUI: Check the start of the MIME string instead of doing single checks of the whole string

 fractal-gtk/src/appop/message.rs | 30 +++---------------------------
 1 file changed, 3 insertions(+), 27 deletions(-)
---
diff --git a/fractal-gtk/src/appop/message.rs b/fractal-gtk/src/appop/message.rs
index a8dc950c..7ff02ad1 100644
--- a/fractal-gtk/src/appop/message.rs
+++ b/fractal-gtk/src/appop/message.rs
@@ -277,35 +277,11 @@ impl AppOp {
                         .get_content_type()
                         .expect("Could not parse content type from file");
                     let mtype = match mime.as_ref() {
-                        "image/gif" => "m.image",
-                        "image/png" => "m.image",
-                        "image/jpeg" => "m.image",
-                        "image/jpg" => "m.image",
-                        "audio/mp4" => "m.audio",
-                        "audio/webm" => "m.audio",
-                        "audio/aac" => "m.audio",
-                        "audio/mpeg" => "m.audio",
-                        "audio/ogg" => "m.audio",
-                        "audio/wave" => "m.audio",
-                        "audio/wav" => "m.audio",
-                        "audio/x-wav" => "m.audio",
-                        "audio/x-pn-wav" => "m.audio",
-                        "audio/flac" => "m.audio",
-                        "audio/x-flac" => "m.audio",
+                        m if m.starts_with("image") => "m.image",
+                        m if m.starts_with("audio") => "m.audio",
                         "application/x-riff" => "m.audio",
-                        "video/x-msvideo" => "m.video",
-                        "video/mpeg" => "m.video",
-                        "video/ogg" => "m.video",
-                        "video/mp2t" => "m.video",
-                        "video/webm" => "m.video",
-                        "video/3gpp" => "m.video",
-                        "video/3gpp2" => "m.video",
-                        "video/x-flv" => "m.video",
-                        "video/mp4" => "m.video",
+                        m if m.starts_with("video") => "m.video",
                         "application/x-mpegURL" => "m.video",
-                        "video/MP2T" => "m.video",
-                        "video/quicktime" => "m.video",
-                        "video/x-ms-wmv" => "m.video",
                         _ => "m.file",
                     };
                     let body = path


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]