[fractal/fractal-next] verification: Hide error when user cancels
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] verification: Hide error when user cancels
- Date: Thu, 13 Jan 2022 14:34:42 +0000 (UTC)
commit d42f5383969ffdc5952c84357ec1761c0b9e2479
Author: Julian Sparber <julian sparber net>
Date: Wed Jan 12 19:33:13 2022 +0100
verification: Hide error when user cancels
.../content/room_history/verification_info_bar.rs | 2 +-
.../verification/identity_verification_widget.rs | 2 +-
.../content/verification/session_verification.rs | 4 ++--
src/session/verification/identity_verification.rs | 23 +++++++++++++++++-----
4 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/src/session/content/room_history/verification_info_bar.rs
b/src/session/content/room_history/verification_info_bar.rs
index 10b06ceb..b1175284 100644
--- a/src/session/content/room_history/verification_info_bar.rs
+++ b/src/session/content/room_history/verification_info_bar.rs
@@ -43,7 +43,7 @@ mod imp {
});
klass.install_action("verification.decline", None, move |widget, _, _| {
- widget.request().unwrap().cancel();
+ widget.request().unwrap().cancel(true);
});
}
diff --git a/src/session/content/verification/identity_verification_widget.rs
b/src/session/content/verification/identity_verification_widget.rs
index 04c5294f..4e0f1647 100644
--- a/src/session/content/verification/identity_verification_widget.rs
+++ b/src/session/content/verification/identity_verification_widget.rs
@@ -389,7 +389,7 @@ impl IdentityVerificationWidget {
pub fn decline(&self) {
if let Some(request) = self.request() {
- request.cancel();
+ request.cancel(true);
}
}
diff --git a/src/session/content/verification/session_verification.rs
b/src/session/content/verification/session_verification.rs
index d0e6105a..a4101eec 100644
--- a/src/session/content/verification/session_verification.rs
+++ b/src/session/content/verification/session_verification.rs
@@ -123,7 +123,7 @@ mod imp {
fn dispose(&self, obj: &Self::Type) {
if let Some(request) = obj.request() {
- request.cancel();
+ request.cancel(true);
}
}
}
@@ -173,7 +173,7 @@ impl SessionVerification {
previous_request.disconnect(handler);
}
- previous_request.cancel();
+ previous_request.cancel(true);
}
if let Some(ref request) = request {
diff --git a/src/session/verification/identity_verification.rs
b/src/session/verification/identity_verification.rs
index 171b2fb7..aa42e940 100644
--- a/src/session/verification/identity_verification.rs
+++ b/src/session/verification/identity_verification.rs
@@ -140,6 +140,7 @@ mod imp {
pub flow_id: OnceCell<String>,
pub start_time: OnceCell<glib::DateTime>,
pub receive_time: OnceCell<glib::DateTime>,
+ pub hide_error: Cell<bool>,
}
#[glib::object_subclass]
@@ -300,7 +301,7 @@ mod imp {
}
fn dispose(&self, obj: &Self::Type) {
- obj.cancel();
+ obj.cancel(true);
}
}
}
@@ -463,7 +464,7 @@ impl IdentityVerification {
if difference < 0 {
warn!("The verification request was sent in the future.");
- self.cancel();
+ self.cancel(false);
return;
}
let difference = Duration::from_secs(difference as u64);
@@ -474,14 +475,14 @@ impl IdentityVerification {
let remaining = std::cmp::max(remaining_creation, remaining_receive);
if remaining.is_zero() {
- self.cancel();
+ self.cancel(false);
return;
}
glib::source::timeout_add_local(
remaining,
clone!(@weak self as obj => @default-return glib::Continue(false), move || {
- obj.cancel();
+ obj.cancel(false);
glib::Continue(false)
}),
@@ -581,7 +582,16 @@ impl IdentityVerification {
)
}
+ fn hide_error(&self) -> bool {
+ let priv_ = imp::IdentityVerification::from_instance(self);
+ priv_.hide_error.get()
+ }
+
fn show_error(&self) {
+ if self.hide_error() {
+ return;
+ }
+
let error_message = if let Some(info) = self.cancel_info() {
match info.cancel_code() {
CancelCode::User => Some(gettext("You cancelled the verificaiton process.")),
@@ -695,8 +705,11 @@ impl IdentityVerification {
}
}
- pub fn cancel(&self) {
+ pub fn cancel(&self, hide_error: bool) {
let priv_ = imp::IdentityVerification::from_instance(self);
+
+ priv_.hide_error.set(hide_error);
+
if let Some(sync_sender) = &*priv_.sync_sender.borrow() {
let result = sync_sender.try_send(Message::UserAction(UserAction::Cancel));
if let Err(error) = result {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]