Merge pull request #557 from iamkartiknayak/fix/duplicate-sidebar-entries

fix(sidebar): prevent duplicate entries of the same item
This commit is contained in:
Jeremy Soller 2024-10-03 16:03:20 -06:00 committed by GitHub
commit ce91ed3f24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1348,7 +1348,10 @@ impl Application for App {
Message::AddToSidebar(entity_opt) => {
let mut favorites = self.config.favorites.clone();
for path in self.selected_paths(entity_opt) {
favorites.push(Favorite::from_path(path));
let favorite = Favorite::from_path(path);
if !favorites.iter().any(|f| f == &favorite) {
favorites.push(favorite);
}
}
config_set!(favorites, favorites);
return self.update_config();