conf/accounts: call is_online if Refresh job fails
parent
281a6ee6ae
commit
46e3bb8074
|
@ -141,7 +141,6 @@ pub struct Account {
|
||||||
name: String,
|
name: String,
|
||||||
hash: AccountHash,
|
hash: AccountHash,
|
||||||
pub is_online: Result<()>,
|
pub is_online: Result<()>,
|
||||||
pub last_online_request: std::time::Instant,
|
|
||||||
pub(crate) mailbox_entries: IndexMap<MailboxHash, MailboxEntry>,
|
pub(crate) mailbox_entries: IndexMap<MailboxHash, MailboxEntry>,
|
||||||
pub(crate) mailboxes_order: Vec<MailboxHash>,
|
pub(crate) mailboxes_order: Vec<MailboxHash>,
|
||||||
tree: Vec<MailboxNode>,
|
tree: Vec<MailboxNode>,
|
||||||
|
@ -429,7 +428,6 @@ impl Account {
|
||||||
} else {
|
} else {
|
||||||
Err(MeliError::new("Attempting connection."))
|
Err(MeliError::new("Attempting connection."))
|
||||||
},
|
},
|
||||||
last_online_request: std::time::Instant::now(),
|
|
||||||
mailbox_entries: Default::default(),
|
mailbox_entries: Default::default(),
|
||||||
mailboxes_order: Default::default(),
|
mailboxes_order: Default::default(),
|
||||||
tree: Default::default(),
|
tree: Default::default(),
|
||||||
|
@ -895,6 +893,13 @@ impl Account {
|
||||||
}
|
}
|
||||||
RefreshEventKind::Failure(err) => {
|
RefreshEventKind::Failure(err) => {
|
||||||
debug!("RefreshEvent Failure: {}", err.to_string());
|
debug!("RefreshEvent Failure: {}", err.to_string());
|
||||||
|
while let Some((job_id, _)) =
|
||||||
|
self.active_jobs.iter().find(|(_, j)| j.is_watch())
|
||||||
|
{
|
||||||
|
let job_id = *job_id;
|
||||||
|
let j = self.active_jobs.remove(&job_id);
|
||||||
|
drop(j);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
context
|
context
|
||||||
.1
|
.1
|
||||||
|
@ -907,7 +912,7 @@ impl Account {
|
||||||
*/
|
*/
|
||||||
self.watch();
|
self.watch();
|
||||||
return Some(Notification(
|
return Some(Notification(
|
||||||
None,
|
Some("Account watch failed".into()),
|
||||||
err.to_string(),
|
err.to_string(),
|
||||||
Some(crate::types::NotificationType::ERROR),
|
Some(crate::types::NotificationType::ERROR),
|
||||||
));
|
));
|
||||||
|
@ -1563,7 +1568,6 @@ impl Account {
|
||||||
{
|
{
|
||||||
self.watch();
|
self.watch();
|
||||||
}
|
}
|
||||||
self.last_online_request = std::time::Instant::now();
|
|
||||||
self.is_online = Ok(());
|
self.is_online = Ok(());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1578,8 +1582,8 @@ impl Account {
|
||||||
}
|
}
|
||||||
JobRequest::Refresh(_mailbox_hash, _, ref mut chan) => {
|
JobRequest::Refresh(_mailbox_hash, _, ref mut chan) => {
|
||||||
let r = chan.try_recv().unwrap();
|
let r = chan.try_recv().unwrap();
|
||||||
if let Some(r) = r {
|
match r {
|
||||||
if r.is_ok() {
|
Some(Ok(())) => {
|
||||||
if self.is_online.is_err()
|
if self.is_online.is_err()
|
||||||
&& !self
|
&& !self
|
||||||
.is_online
|
.is_online
|
||||||
|
@ -1590,23 +1594,39 @@ impl Account {
|
||||||
{
|
{
|
||||||
self.watch();
|
self.watch();
|
||||||
}
|
}
|
||||||
|
if !(self.is_online.is_err()
|
||||||
|
&& self
|
||||||
|
.is_online
|
||||||
|
.as_ref()
|
||||||
|
.unwrap_err()
|
||||||
|
.kind
|
||||||
|
.is_authentication())
|
||||||
|
{
|
||||||
|
self.is_online = Ok(());
|
||||||
|
self.sender
|
||||||
|
.send(ThreadEvent::UIEvent(UIEvent::AccountStatusChange(
|
||||||
|
self.hash,
|
||||||
|
)))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !(self.is_online.is_err()
|
Some(Err(err)) => {
|
||||||
&& self
|
if !err.kind.is_authentication() {
|
||||||
.is_online
|
let online_job = self.backend.read().unwrap().is_online();
|
||||||
.as_ref()
|
if let Ok(online_job) = online_job {
|
||||||
.unwrap_err()
|
let (rcvr, handle, job_id) =
|
||||||
.kind
|
self.job_executor.spawn_specialized(online_job);
|
||||||
.is_authentication())
|
self.insert_job(job_id, JobRequest::IsOnline(handle, rcvr));
|
||||||
{
|
};
|
||||||
self.last_online_request = std::time::Instant::now();
|
}
|
||||||
self.is_online = Ok(());
|
self.is_online = Err(err);
|
||||||
self.sender
|
self.sender
|
||||||
.send(ThreadEvent::UIEvent(UIEvent::AccountStatusChange(
|
.send(ThreadEvent::UIEvent(UIEvent::AccountStatusChange(
|
||||||
self.hash,
|
self.hash,
|
||||||
)))
|
)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JobRequest::SetFlags(_, _, ref mut chan) => {
|
JobRequest::SetFlags(_, _, ref mut chan) => {
|
||||||
|
|
Loading…
Reference in New Issue