Add ability to remove files from Recents
This commit is contained in:
parent
5a01fb95ff
commit
54b884e5f8
6 changed files with 63 additions and 3 deletions
|
|
@ -523,6 +523,9 @@ pub enum Operation {
|
|||
PermanentlyDelete {
|
||||
paths: Vec<PathBuf>,
|
||||
},
|
||||
RemoveFromRecents {
|
||||
paths: Vec<PathBuf>,
|
||||
},
|
||||
Rename {
|
||||
from: PathBuf,
|
||||
to: PathBuf,
|
||||
|
|
@ -635,6 +638,7 @@ impl Operation {
|
|||
Self::Rename { from, to } => {
|
||||
fl!("renaming", from = file_name(from), to = file_name(to))
|
||||
}
|
||||
Self::RemoveFromRecents { paths } => fl!("removing-from-recents", items = paths.len()),
|
||||
Self::Restore { items } => fl!("restoring", items = items.len(), progress = progress()),
|
||||
Self::SetExecutableAndLaunch { path } => {
|
||||
fl!("setting-executable-and-launching", name = file_name(path))
|
||||
|
|
@ -698,6 +702,7 @@ impl Operation {
|
|||
parent = parent_name(path)
|
||||
),
|
||||
Self::PermanentlyDelete { paths } => fl!("permanently-deleted", items = paths.len()),
|
||||
Self::RemoveFromRecents { paths } => fl!("removed-from-recents", items = paths.len()),
|
||||
Self::Rename { from, to } => fl!("renamed", from = file_name(from), to = file_name(to)),
|
||||
Self::Restore { items } => fl!("restored", items = items.len()),
|
||||
Self::SetExecutableAndLaunch { path } => {
|
||||
|
|
@ -727,6 +732,7 @@ impl Operation {
|
|||
| Self::Restore { .. } => true,
|
||||
Self::NewFile { .. }
|
||||
| Self::NewFolder { .. }
|
||||
| Self::RemoveFromRecents { .. }
|
||||
| Self::Rename { .. }
|
||||
| Self::SetExecutableAndLaunch { .. }
|
||||
| Self::SetPermissions { .. } => false,
|
||||
|
|
@ -1154,6 +1160,17 @@ impl Operation {
|
|||
|
||||
Ok(OperationSelection::default())
|
||||
}
|
||||
Self::RemoveFromRecents { paths } => {
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let path_refs = paths.iter().map(|p| p.as_ref()).collect::<Vec<&Path>>();
|
||||
recently_used_xbel::remove_recently_used(&path_refs)
|
||||
})
|
||||
.await
|
||||
.map_err(OperationError::from_str)?
|
||||
.map_err(OperationError::from_str)?;
|
||||
|
||||
Ok(OperationSelection::default())
|
||||
}
|
||||
Self::Rename { from, to } => compio::runtime::spawn(async move {
|
||||
controller.check().await.map_err(OperationError::from_str)?;
|
||||
compio::fs::rename(&from, &to)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue