From 8fed9dd21621efdfa4f0c022e255286a8e0d8724 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 28 Feb 2024 14:42:46 -0700 Subject: [PATCH] Manually rescan any trash tabs after operation is completed --- src/app.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/app.rs b/src/app.rs index ea40414..2309cf4 100644 --- a/src/app.rs +++ b/src/app.rs @@ -249,6 +249,23 @@ impl App { ) } + fn rescan_trash(&mut self) -> Command { + let mut needs_reload = Vec::new(); + for entity in self.tab_model.iter() { + if let Some(tab) = self.tab_model.data::(entity) { + if let Location::Trash = &tab.location { + needs_reload.push((entity, Location::Trash)); + } + } + } + + let mut commands = Vec::with_capacity(needs_reload.len()); + for (entity, location) in needs_reload { + commands.push(self.rescan_tab(entity, location)); + } + Command::batch(commands) + } + fn update_config(&mut self) -> Command { cosmic::app::command::set_theme(self.config.app_theme.theme()) } @@ -798,12 +815,16 @@ impl Application for App { if let Some((op, _)) = self.pending_operations.remove(&id) { self.complete_operations.insert(id, op); } + // Manually rescan any trash tabs after any operation is completed + return self.rescan_trash(); } Message::PendingError(id, err) => { if let Some((op, _)) = self.pending_operations.remove(&id) { self.failed_operations.insert(id, (op, err)); self.dialog_pages.push_back(DialogPage::FailedOperation(id)); } + // Manually rescan any trash tabs after any operation is completed + return self.rescan_trash(); } Message::PendingProgress(id, new_progress) => { if let Some((_, progress)) = self.pending_operations.get_mut(&id) {