♻️ 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:
committed by
Jeremiah Russell
parent
01b9e7677d
commit
dbc023d761
10
src/trash.rs
10
src/trash.rs
@@ -20,14 +20,18 @@ impl Trash {
|
||||
&mut self.message_list
|
||||
}
|
||||
|
||||
/// Run the trash cli
|
||||
pub async fn run(&mut self, pages: u32) -> Result<()> {
|
||||
/// Prepare the trash cli
|
||||
pub async fn prepare(&mut self, pages: u32) -> Result<()> {
|
||||
self.message_list.run(pages).await?;
|
||||
self.batch_move_to_trash().await?;
|
||||
|
||||
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<()> {
|
||||
let add_label_ids = Some(Vec::from(["TRASH".to_string()]));
|
||||
let ids = Some(self.message_list.message_ids());
|
||||
|
||||
Reference in New Issue
Block a user