Skip to content

Commit

Permalink
emit items changed on update added
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaDve committed Dec 27, 2023
1 parent 5f027de commit 064259d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/recent_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,30 +147,30 @@ impl RecentList {
pub fn add(&self, uri: String) {
let imp = self.imp();

let index = match imp.list.borrow_mut().entry(uri) {
let (index, removed, added) = match imp.list.borrow_mut().entry(uri) {
Entry::Vacant(entry) => {
let uri = entry.key();
let index = entry.index();

let uri = entry.key();
let item = RecentItem::new(
&gio::File::for_uri(uri),
&glib::DateTime::now_utc().unwrap(),
);
entry.insert(item);

Some(index)
(index, 0, 1)
}
Entry::Occupied(entry) => {
let index = entry.index();

let item = entry.get();
item.set_added(glib::DateTime::now_utc().unwrap());

None
(index, 1, 1)
}
};

if let Some(index) = index {
self.items_changed(index as u32, 0, 1);
}
self.items_changed(index as u32, removed, added);
}

pub fn remove(&self, uri: &str) {
Expand Down

0 comments on commit 064259d

Please sign in to comment.