mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
remove history items limit
This commit is contained in:
parent
cd9e786640
commit
846c488480
4 changed files with 7 additions and 14 deletions
|
|
@ -9,10 +9,6 @@ use std::rc::Rc;
|
||||||
// Config options
|
// Config options
|
||||||
|
|
||||||
const LABEL_MAX_LENGTH: usize = 32;
|
const LABEL_MAX_LENGTH: usize = 32;
|
||||||
const RECENT_BOOKMARKS: usize = 50;
|
|
||||||
const RECENTLY_CLOSED: usize = 50;
|
|
||||||
const RECENT_REQUESTS: usize = 50;
|
|
||||||
|
|
||||||
pub struct Menu {
|
pub struct Menu {
|
||||||
pub menu_button: MenuButton,
|
pub menu_button: MenuButton,
|
||||||
}
|
}
|
||||||
|
|
@ -195,7 +191,7 @@ impl Menu {
|
||||||
move |_| {
|
move |_| {
|
||||||
// Bookmarks
|
// Bookmarks
|
||||||
main_bookmarks.remove_all();
|
main_bookmarks.remove_all();
|
||||||
for request in profile.bookmark.memory.recent(RECENT_BOOKMARKS) {
|
for request in profile.bookmark.memory.recent() {
|
||||||
let menu_item = gio::MenuItem::new(Some(&label(&request, LABEL_MAX_LENGTH)), None);
|
let menu_item = gio::MenuItem::new(Some(&label(&request, LABEL_MAX_LENGTH)), None);
|
||||||
menu_item.set_action_and_target_value(Some(&format!(
|
menu_item.set_action_and_target_value(Some(&format!(
|
||||||
"{}.{}",
|
"{}.{}",
|
||||||
|
|
@ -212,7 +208,7 @@ impl Menu {
|
||||||
|
|
||||||
// Recently closed history
|
// Recently closed history
|
||||||
main_history_tab.remove_all();
|
main_history_tab.remove_all();
|
||||||
for item in profile.history.memory.tab.recent(RECENTLY_CLOSED) {
|
for item in profile.history.memory.tab.recent() {
|
||||||
let item_request = item.page.navigation.request.widget.entry.text(); // @TODO restore entire `Item`
|
let item_request = item.page.navigation.request.widget.entry.text(); // @TODO restore entire `Item`
|
||||||
let menu_item = gio::MenuItem::new(Some(&label(&item_request, LABEL_MAX_LENGTH)), None);
|
let menu_item = gio::MenuItem::new(Some(&label(&item_request, LABEL_MAX_LENGTH)), None);
|
||||||
menu_item.set_action_and_target_value(Some(&format!(
|
menu_item.set_action_and_target_value(Some(&format!(
|
||||||
|
|
@ -226,7 +222,7 @@ impl Menu {
|
||||||
|
|
||||||
// Recently visited history
|
// Recently visited history
|
||||||
main_history_request.remove_all();
|
main_history_request.remove_all();
|
||||||
for request in profile.history.memory.request.recent(RECENT_REQUESTS) {
|
for request in profile.history.memory.request.recent() {
|
||||||
let menu_item = gio::MenuItem::new(Some(&label(&request, LABEL_MAX_LENGTH)), None);
|
let menu_item = gio::MenuItem::new(Some(&label(&request, LABEL_MAX_LENGTH)), None);
|
||||||
menu_item.set_action_and_target_value(Some(&format!(
|
menu_item.set_action_and_target_value(Some(&format!(
|
||||||
"{}.{}",
|
"{}.{}",
|
||||||
|
|
|
||||||
|
|
@ -63,14 +63,13 @@ impl Memory {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get recent requests vector sorted by `ID` DESC
|
/// Get recent requests vector sorted by `ID` DESC
|
||||||
pub fn recent(&self, limit: usize) -> Vec<String> {
|
pub fn recent(&self) -> Vec<String> {
|
||||||
let mut recent: Vec<String> = Vec::new();
|
let mut recent: Vec<String> = Vec::new();
|
||||||
for (request, _) in self
|
for (request, _) in self
|
||||||
.index
|
.index
|
||||||
.borrow()
|
.borrow()
|
||||||
.iter()
|
.iter()
|
||||||
.sorted_by(|a, b| Ord::cmp(&b.1, &a.1))
|
.sorted_by(|a, b| Ord::cmp(&b.1, &a.1))
|
||||||
.take(limit)
|
|
||||||
{
|
{
|
||||||
recent.push(request.to_string())
|
recent.push(request.to_string())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,13 @@ impl Request {
|
||||||
|
|
||||||
/// Get recent requests vector
|
/// Get recent requests vector
|
||||||
/// * sorted by `unix_timestamp` DESC
|
/// * sorted by `unix_timestamp` DESC
|
||||||
pub fn recent(&self, limit: usize) -> Vec<GString> {
|
pub fn recent(&self) -> Vec<GString> {
|
||||||
let mut recent: Vec<GString> = Vec::new();
|
let mut recent: Vec<GString> = Vec::new();
|
||||||
for (request, _) in self
|
for (request, _) in self
|
||||||
.index
|
.index
|
||||||
.borrow()
|
.borrow()
|
||||||
.iter()
|
.iter()
|
||||||
.sorted_by(|a, b| Ord::cmp(&b.1.unix_timestamp, &a.1.unix_timestamp))
|
.sorted_by(|a, b| Ord::cmp(&b.1.unix_timestamp, &a.1.unix_timestamp))
|
||||||
.take(limit)
|
|
||||||
{
|
{
|
||||||
recent.push(request.clone())
|
recent.push(request.clone())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,15 +39,14 @@ impl Tab {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get recent `Item` vector sorted by time DESC
|
/// Get recent `Item` vector sorted by `unix_timestamp` DESC
|
||||||
pub fn recent(&self, limit: usize) -> Vec<Rc<Item>> {
|
pub fn recent(&self) -> Vec<Rc<Item>> {
|
||||||
let mut recent: Vec<Rc<Item>> = Vec::new();
|
let mut recent: Vec<Rc<Item>> = Vec::new();
|
||||||
for record in self
|
for record in self
|
||||||
.index
|
.index
|
||||||
.borrow()
|
.borrow()
|
||||||
.iter()
|
.iter()
|
||||||
.sorted_by(|a, b| Ord::cmp(&b.unix_timestamp, &a.unix_timestamp))
|
.sorted_by(|a, b| Ord::cmp(&b.unix_timestamp, &a.unix_timestamp))
|
||||||
.take(limit)
|
|
||||||
{
|
{
|
||||||
recent.push(record.item.clone())
|
recent.push(record.item.clone())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue