fix: wire initial sync, oauth flow, and eliminate warnings

- Add token_file_exists() to ApiClient for sync token check
- App::new now checks for token on startup; shows DeviceAuth popup if missing
- Background thread starts OAuth Device Flow automatically when no token
- App::poll_auth() called each frame to detect auth completion
- Auth completion triggers SyncCommand::InitialSync
- run_initial_sync fetches all lists and tasks via Google Tasks API
- Stores results in local DB via replace_all_lists / replace_all_tasks
- App::check_initial_load() refreshes UI from DB after initial sync
- Removed all compile warnings (dead_code annotations)
This commit is contained in:
Ruben Rosario
2026-06-20 19:51:10 +01:00
parent 71befdf9f8
commit 320a9c2572
3 changed files with 149 additions and 32 deletions
+8
View File
@@ -17,6 +17,7 @@ pub struct OAuthToken {
}
#[derive(Debug)]
#[allow(dead_code)]
pub enum ApiError {
Network(String),
Auth(String),
@@ -47,6 +48,13 @@ impl ApiClient {
}
}
pub fn token_file_exists(&self) -> bool {
self.token_path.exists() && std::fs::read_to_string(&self.token_path)
.ok()
.and_then(|s| serde_json::from_str::<OAuthToken>(&s).ok())
.is_some()
}
pub async fn load_token(&self) -> Option<OAuthToken> {
let content = std::fs::read_to_string(&self.token_path).ok()?;
serde_json::from_str(&content).ok()