♻️ refactor(trash): separate trash preparation and execution

- split the run function into prepare and batch_trash
- prepare is for fetching the list, batch_trash will execute the move to trash
This commit is contained in:
Jeremiah Russell
2025-10-11 06:54:50 +01:00
committed by Jeremiah Russell
parent 01b9e7677d
commit dbc023d761

View File

@@ -20,14 +20,18 @@ impl Trash {
&mut self.message_list &mut self.message_list
} }
/// Run the trash cli /// Prepare the trash cli
pub async fn run(&mut self, pages: u32) -> Result<()> { pub async fn prepare(&mut self, pages: u32) -> Result<()> {
self.message_list.run(pages).await?; self.message_list.run(pages).await?;
self.batch_move_to_trash().await?;
Ok(()) Ok(())
} }
/// Move the messages to trash
pub async fn batch_trash(&self) -> Result<()> {
self.batch_move_to_trash().await
}
async fn batch_move_to_trash(&self) -> Result<()> { async fn batch_move_to_trash(&self) -> Result<()> {
let add_label_ids = Some(Vec::from(["TRASH".to_string()])); let add_label_ids = Some(Vec::from(["TRASH".to_string()]));
let ids = Some(self.message_list.message_ids()); let ids = Some(self.message_list.message_ids());