diff --git a/src/app/browser/window/header/bar/menu.rs b/src/app/browser/window/header/bar/menu.rs index 292e0dff..2c9ff877 100644 --- a/src/app/browser/window/header/bar/menu.rs +++ b/src/app/browser/window/header/bar/menu.rs @@ -207,7 +207,7 @@ impl Menu for MenuButton { move |_| { // Bookmarks main_bookmarks.remove_all(); - for bookmark in profile.bookmark.recent() { + for bookmark in profile.bookmark.recent(None) { let menu_item = gio::MenuItem::new(Some(&ellipsize(&bookmark.request, LABEL_MAX_LENGTH)), None); menu_item.set_action_and_target_value(Some(&format!( "{}.{}", diff --git a/src/profile/bookmark.rs b/src/profile/bookmark.rs index 6878ff71..632e4073 100644 --- a/src/profile/bookmark.rs +++ b/src/profile/bookmark.rs @@ -68,8 +68,8 @@ impl Bookmark { } /// Get recent Items vector from `memory`, sorted by `ID` DESC - pub fn recent(&self) -> Vec { - self.memory.borrow().recent() + pub fn recent(&self, limit: Option) -> Vec { + self.memory.borrow().recent(limit) } } diff --git a/src/profile/bookmark/memory.rs b/src/profile/bookmark/memory.rs index a0fb4747..c1a4304b 100644 --- a/src/profile/bookmark/memory.rs +++ b/src/profile/bookmark/memory.rs @@ -40,13 +40,17 @@ impl Memory { } /// Get recent Items vector sorted by `ID` DESC - pub fn recent(&self) -> Vec { + pub fn recent(&self, limit: Option) -> Vec { let mut recent: Vec = Vec::new(); - for item in self + for (i, item) in self .0 .iter() .sorted_by(|a, b| Ord::cmp(&b.request, &a.request)) + .enumerate() { + if limit.is_some_and(|l| i > l) { + break; + } recent.push(item.clone()) } recent