Update OptHelper, current only an instance in whole programs

This commit is contained in:
2022-05-30 10:44:33 +00:00
committed by GitHub
parent 3f2a9d6ff6
commit c00fbfde9c
7 changed files with 130 additions and 94 deletions

View File

@@ -1,6 +1,6 @@
use crate::author_name_filter::AuthorFiler;
use crate::gettext;
use crate::opthelper::OptHelper;
use crate::opthelper::get_helper;
use crate::pixiv_link::ToPixivID;
use crate::pixiv_link::PixivID;
use json::JsonValue;
@@ -16,11 +16,10 @@ pub struct PixivData {
/// The author
pub author: Option<String>,
pub description: Option<String>,
helper: OptHelper,
}
impl PixivData {
pub fn new<T: ToPixivID>(id: T, helper: OptHelper) -> Option<Self> {
pub fn new<T: ToPixivID>(id: T) -> Option<Self> {
let i = id.to_pixiv_id();
if i.is_none() {
return None;
@@ -30,7 +29,6 @@ impl PixivData {
title: None,
author: None,
description: None,
helper: helper,
})
}
@@ -59,7 +57,7 @@ impl PixivData {
let author = value["userName"].as_str();
if author.is_some() {
let au = author.unwrap();
match self.helper.author_name_filters() {
match get_helper().author_name_filters() {
Some(l) => { self.author = Some(l.filter(au)) }
None => { self.author = Some(String::from(author.unwrap())); }
}