refactor
This commit is contained in:
@@ -217,8 +217,6 @@ impl RelayAuth {
|
||||
.send_msg(ClientMessage::Auth(Cow::Borrowed(&event)))
|
||||
.await?;
|
||||
|
||||
log::info!("Sending AUTH event");
|
||||
|
||||
while let Some(notification) = notifications.next().await {
|
||||
match notification {
|
||||
RelayNotification::Message { message } => {
|
||||
@@ -272,29 +270,24 @@ impl RelayAuth {
|
||||
this.update_in(cx, |this, window, cx| {
|
||||
window.clear_notification_by_id::<AuthNotification>(challenge, cx);
|
||||
|
||||
match result {
|
||||
Ok(_) => {
|
||||
// Clear pending events for the authenticated relay
|
||||
this.clear_pending_events(url, cx);
|
||||
if let Err(e) = result {
|
||||
window
|
||||
.push_notification(Notification::error(e.to_string()).autohide(false), cx);
|
||||
} else {
|
||||
// Clear pending events for the authenticated relay
|
||||
this.clear_pending_events(url, cx);
|
||||
|
||||
// Only show the success notification if the relay was not already trusted
|
||||
if !settings.read(cx).trusted_relay(url, cx) {
|
||||
let domain = url.domain().unwrap_or_default();
|
||||
let msg = format!("Relay {} has been authenticated", domain);
|
||||
|
||||
window.push_notification(Notification::success(msg), cx);
|
||||
} else {
|
||||
// Save the authenticated relay to automatically authenticate future requests
|
||||
settings.update(cx, |this, cx| {
|
||||
this.add_trusted_relay(url, cx);
|
||||
});
|
||||
|
||||
window.push_notification(
|
||||
Notification::success(format!(
|
||||
"Relay {} has been authenticated",
|
||||
url.domain().unwrap_or_default()
|
||||
)),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
window.push_notification(
|
||||
Notification::error(e.to_string()).autohide(false),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user