[fractal/fractal-next] verification: Implement decimal fallback for Sas



commit 7b608f0c7d8475b7437af5a41b6df9c6e59df27d
Author: Julian Sparber <julian sparber net>
Date:   Fri Dec 17 18:03:38 2021 +0100

    verification: Implement decimal fallback for Sas

 .../verification/identity_verification_widget.rs   | 27 ++++++++++++++-------
 .../content/verification/session_verification.rs   | 28 +++++++++++++++-------
 2 files changed, 39 insertions(+), 16 deletions(-)
---
diff --git a/src/session/content/verification/identity_verification_widget.rs 
b/src/session/content/verification/identity_verification_widget.rs
index 9ee9c651..f7fc86f4 100644
--- a/src/session/content/verification/identity_verification_widget.rs
+++ b/src/session/content/verification/identity_verification_widget.rs
@@ -358,17 +358,28 @@ impl IdentityVerificationWidget {
                 }
                 VerificationMode::SasV1 => {
                     self.clean_emoji();
-                    // TODO: implement sas fallback when emojis arn't supported
-                    if let Some(SasData::Emoji(emoji)) = request.sas_data() {
-                        for (index, emoji) in emoji.iter().enumerate() {
-                            if index < 4 {
-                                priv_.emoji_row_1.append(&Emoji::new(emoji));
-                            } else {
-                                priv_.emoji_row_2.append(&Emoji::new(emoji));
+                    match request.sas_data().unwrap() {
+                        SasData::Emoji(emoji) => {
+                            for (index, emoji) in emoji.iter().enumerate() {
+                                if index < 4 {
+                                    priv_.emoji_row_1.append(&Emoji::new(emoji));
+                                } else {
+                                    priv_.emoji_row_2.append(&Emoji::new(emoji));
+                                }
                             }
                         }
-                        priv_.main_stack.set_visible_child_name("emoji");
+                        SasData::Decimal((a, b, c)) => {
+                            let container = gtk::Box::builder()
+                                .spacing(24)
+                                .css_classes(vec!["emoji".to_string()])
+                                .build();
+                            container.append(&gtk::Label::builder().label(&a.to_string()).build());
+                            container.append(&gtk::Label::builder().label(&b.to_string()).build());
+                            container.append(&gtk::Label::builder().label(&c.to_string()).build());
+                            priv_.emoji_row_1.append(&container);
+                        }
                     }
+                    priv_.main_stack.set_visible_child_name("emoji");
                 }
                 VerificationMode::Completed => {
                     priv_.main_stack.set_visible_child_name("completed");
diff --git a/src/session/content/verification/session_verification.rs 
b/src/session/content/verification/session_verification.rs
index fa14ca35..0e3a6571 100644
--- a/src/session/content/verification/session_verification.rs
+++ b/src/session/content/verification/session_verification.rs
@@ -321,17 +321,29 @@ impl SessionVerification {
                 self.start_scanning();
             }
             VerificationMode::SasV1 => {
-                // TODO: implement sas fallback when emojis arn't supported
-                if let Some(SasData::Emoji(emoji)) = request.sas_data() {
-                    for (index, emoji) in emoji.iter().enumerate() {
-                        if index < 4 {
-                            priv_.emoji_row_1.append(&Emoji::new(emoji));
-                        } else {
-                            priv_.emoji_row_2.append(&Emoji::new(emoji));
+                match request.sas_data().unwrap() {
+                    SasData::Emoji(emoji) => {
+                        for (index, emoji) in emoji.iter().enumerate() {
+                            if index < 4 {
+                                priv_.emoji_row_1.append(&Emoji::new(emoji));
+                            } else {
+                                priv_.emoji_row_2.append(&Emoji::new(emoji));
+                            }
                         }
                     }
-                    priv_.main_stack.set_visible_child_name("emoji");
+                    SasData::Decimal((a, b, c)) => {
+                        let container = gtk::Box::builder()
+                            .spacing(24)
+                            .css_classes(vec!["emoji".to_string()])
+                            .build();
+                        container.append(&gtk::Label::builder().label(&a.to_string()).build());
+                        container.append(&gtk::Label::builder().label(&b.to_string()).build());
+                        container.append(&gtk::Label::builder().label(&c.to_string()).build());
+                        priv_.emoji_row_1.append(&container);
+                    }
                 }
+
+                priv_.main_stack.set_visible_child_name("emoji");
             }
             VerificationMode::Completed => {
                 priv_.main_stack.set_visible_child_name("completed");


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