verification: Use IdentityVerificationWidget::is_finished() where possible

This commit is contained in:
Julian Sparber 2021-12-17 18:37:57 +01:00
parent 7b608f0c7d
commit 9696627bfb

View file

@ -14,7 +14,7 @@ use self::verification::IdentityVerificationWidget;
use crate::session::sidebar::{Entry, EntryType}; use crate::session::sidebar::{Entry, EntryType};
use crate::session::verification::{IdentityVerification, VerificationMode}; use crate::session::verification::IdentityVerification;
use adw::subclass::prelude::*; use adw::subclass::prelude::*;
use gtk::{gio, glib, glib::clone, prelude::*, subclass::prelude::*, CompositeTemplate}; use gtk::{gio, glib, glib::clone, prelude::*, subclass::prelude::*, CompositeTemplate};
@ -219,12 +219,15 @@ impl Content {
} }
if item.is::<IdentityVerification>() { if item.is::<IdentityVerification>() {
let handler_id = item.connect_notify_local(Some("mode"), clone!(@weak self as obj => move |request, _| { let handler_id = item.connect_notify_local(
Some("mode"),
clone!(@weak self as obj => move |request, _| {
let request = request.downcast_ref::<IdentityVerification>().unwrap(); let request = request.downcast_ref::<IdentityVerification>().unwrap();
if request.mode() == VerificationMode::Cancelled || request.mode() == VerificationMode::Error || request.mode() == VerificationMode::Dismissed { if request.is_finished() {
obj.set_item(None); obj.set_item(None);
} }
})); }),
);
priv_.signal_handler.replace(Some(handler_id)); priv_.signal_handler.replace(Some(handler_id));
} }
} }