use IndexMap to keep index order

This commit is contained in:
yggverse 2025-07-25 16:35:15 +03:00
parent 63c6898aab
commit 02f6419b92
3 changed files with 7 additions and 4 deletions

View file

@ -34,6 +34,7 @@ anyhow = "1.0.97"
async-channel = "2.5.0" async-channel = "2.5.0"
ggemini = "0.19.0" ggemini = "0.19.0"
ggemtext = "0.7.0" ggemtext = "0.7.0"
indexmap = "2.10.0"
itertools = "0.14.0" itertools = "0.14.0"
# libspelling = "0.4.0" # libspelling = "0.4.0"
maxminddb = "0.26.0" maxminddb = "0.26.0"

View file

@ -10,7 +10,8 @@ use adw::{
}, },
}; };
use gtk::glib::{DateTime, GString, Uri, UriFlags}; use gtk::glib::{DateTime, GString, Uri, UriFlags};
use std::{collections::HashMap, rc::Rc}; use indexmap::IndexMap;
use std::rc::Rc;
struct Record { struct Record {
time: DateTime, time: DateTime,
@ -24,7 +25,7 @@ pub trait Bookmarks {
impl Bookmarks for adw::PreferencesDialog { impl Bookmarks for adw::PreferencesDialog {
fn bookmarks(window_action: &Rc<WindowAction>, profile: &Rc<Profile>) -> Self { fn bookmarks(window_action: &Rc<WindowAction>, profile: &Rc<Profile>) -> Self {
let mut index: HashMap<GString, Vec<Record>> = HashMap::new(); let mut index: IndexMap<GString, Vec<Record>> = IndexMap::new();
for bookmark in profile.bookmark.recent(None) { for bookmark in profile.bookmark.recent(None) {
match Uri::parse(&bookmark.request, UriFlags::NONE) { match Uri::parse(&bookmark.request, UriFlags::NONE) {
Ok(uri) => index Ok(uri) => index

View file

@ -10,7 +10,8 @@ use adw::{
}, },
}; };
use gtk::glib::{DateTime, GString, Uri, UriFlags, gformat}; use gtk::glib::{DateTime, GString, Uri, UriFlags, gformat};
use std::{collections::HashMap, rc::Rc}; use indexmap::IndexMap;
use std::rc::Rc;
pub struct Event { pub struct Event {
pub time: DateTime, pub time: DateTime,
@ -29,7 +30,7 @@ pub trait History {
impl History for adw::PreferencesDialog { impl History for adw::PreferencesDialog {
fn history(window_action: &Rc<WindowAction>, profile: &Rc<Profile>) -> Self { fn history(window_action: &Rc<WindowAction>, profile: &Rc<Profile>) -> Self {
let mut visited: HashMap<GString, Vec<Record>> = HashMap::new(); let mut visited: IndexMap<GString, Vec<Record>> = IndexMap::new();
// @TODO recently closed // @TODO recently closed
for history in profile.history.recently_opened(None) { for history in profile.history.recently_opened(None) {