filters: reload current article immediately when preferences closes
This commit is contained in:
parent
b63549ae0a
commit
e5f2d5c941
1 changed files with 23 additions and 0 deletions
|
|
@ -101,6 +101,14 @@ pub mod imp {
|
|||
});
|
||||
klass.install_action("win.preferences", None, |win, _, _| {
|
||||
let dialog = crate::preferences_dialog::PreferencesDialog::new();
|
||||
let win_weak = win.downgrade();
|
||||
dialog.connect_closed(move |_| {
|
||||
if let Some(win) = win_weak.upgrade() {
|
||||
let imp = win.imp();
|
||||
*imp.filter_rules.borrow_mut() = crate::filters::load_rules();
|
||||
imp.reload_current_article();
|
||||
}
|
||||
});
|
||||
dialog.present(Some(win.upcast_ref::<gtk4::Widget>()));
|
||||
});
|
||||
}
|
||||
|
|
@ -234,6 +242,21 @@ pub mod imp {
|
|||
obj.set_unread(false);
|
||||
}
|
||||
|
||||
fn reload_current_article(&self) {
|
||||
let id = self.current_article_id.borrow().clone();
|
||||
let Some(id) = id else { return };
|
||||
if let Some(store) = self.article_store.borrow().as_ref() {
|
||||
for i in 0..store.n_items() {
|
||||
if let Some(obj) = store.item(i).and_downcast::<ArticleObject>() {
|
||||
if obj.article().id == id {
|
||||
self.load_article_in_webview(&obj.article().clone());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn load_article_in_webview(&self, article: &crate::model::Article) {
|
||||
let rules = self.filter_rules.borrow();
|
||||
let content = crate::filters::apply(&rules, &article.id, &article.link, &article.content);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue