Fix list deletion sync: SyncAction::DeleteList
- Added DeleteList variant to SyncAction enum
- Added ApiClient::delete_list() calling DELETE /users/@me/lists/{id}
- List deletion uses DeleteList action (not Delete/delete_task)
- Sync engine handles DeleteList calling api.delete_list()
This commit is contained in:
@@ -402,6 +402,31 @@ impl ApiClient {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_list(&self, list_id: &str) -> Result<(), ApiError> {
|
||||
let token = self.get_token().await?;
|
||||
|
||||
let url = format!(
|
||||
"https://tasks.googleapis.com/tasks/v1/users/@me/lists/{}",
|
||||
list_id
|
||||
);
|
||||
|
||||
let resp = self
|
||||
.client
|
||||
.delete(&url)
|
||||
.bearer_auth(&token)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| ApiError::Network(e.to_string()))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
let status = resp.status();
|
||||
let body = resp.text().await.unwrap_or_default();
|
||||
return Err(ApiError::Api(format!("Delete list failed: {} - {}", status, body)));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn move_task(
|
||||
&self,
|
||||
list_id: &str,
|
||||
|
||||
@@ -282,6 +282,7 @@ impl Db {
|
||||
SyncAction::Delete => "Delete",
|
||||
SyncAction::Reorder => "Reorder",
|
||||
SyncAction::CreateList => "CreateList",
|
||||
SyncAction::DeleteList => "DeleteList",
|
||||
};
|
||||
let conn = self.conn.lock().unwrap();
|
||||
conn.execute(
|
||||
@@ -362,6 +363,7 @@ impl Db {
|
||||
"\"Delete\"" | "Delete" => SyncAction::Delete,
|
||||
"\"Reorder\"" | "Reorder" => SyncAction::Reorder,
|
||||
"\"CreateList\"" | "CreateList" => SyncAction::CreateList,
|
||||
"\"DeleteList\"" | "DeleteList" => SyncAction::DeleteList,
|
||||
_ => SyncAction::Update,
|
||||
};
|
||||
Ok(SyncQueueItem {
|
||||
|
||||
Reference in New Issue
Block a user