mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
fix sync indicator turning blue after startup sync
https://forums.ankiweb.net/t/why-is-my-sync-button-blue/2078/26?u=dae
This commit is contained in:
parent
86108cca55
commit
b48451610f
1 changed files with 8 additions and 2 deletions
|
@ -1541,14 +1541,20 @@ impl Backend {
|
||||||
|
|
||||||
// fetch and cache result
|
// fetch and cache result
|
||||||
let rt = self.runtime_handle();
|
let rt = self.runtime_handle();
|
||||||
|
let time_at_check_begin = TimestampSecs::now();
|
||||||
let remote: SyncMeta = rt.block_on(get_remote_sync_meta(input.into()))?;
|
let remote: SyncMeta = rt.block_on(get_remote_sync_meta(input.into()))?;
|
||||||
let response = self.with_col(|col| col.get_sync_status(remote).map(Into::into))?;
|
let response = self.with_col(|col| col.get_sync_status(remote).map(Into::into))?;
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut guard = self.state.lock().unwrap();
|
let mut guard = self.state.lock().unwrap();
|
||||||
guard.remote_sync_status.last_check = TimestampSecs::now();
|
// On startup, the sync status check will block on network access, and then automatic syncing begins,
|
||||||
|
// taking hold of the mutex. By the time we reach here, our network status may be out of date,
|
||||||
|
// so we discard it if stale.
|
||||||
|
if guard.remote_sync_status.last_check < time_at_check_begin {
|
||||||
|
guard.remote_sync_status.last_check = time_at_check_begin;
|
||||||
guard.remote_sync_status.last_response = response;
|
guard.remote_sync_status.last_response = response;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(response.into())
|
Ok(response.into())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue