Add option to hide score

Add the option to hide score for posts and comments in preferences.
There is still however a blank margin where the score is supposed to be.
This commit is contained in:
gmnsii 2023-03-22 20:08:20 -07:00
parent e25622dac2
commit df3d894947
12 changed files with 36 additions and 5 deletions

View file

@ -52,6 +52,9 @@ pub struct Config {
#[serde(rename = "LIBREDDIT_DEFAULT_HIDE_AWARDS")]
pub(crate) default_hide_awards: Option<String>,
#[serde(rename = "LIBREDDIT_DEFAULT_HIDE_SCORE")]
pub(crate) default_hide_score: Option<String>,
#[serde(rename = "LIBREDDIT_DEFAULT_SUBSCRIPTIONS")]
pub(crate) default_subscriptions: Option<String>,
@ -87,6 +90,7 @@ impl Config {
default_use_hls: parse("LIBREDDIT_DEFAULT_USE_HLS"),
default_hide_hls_notification: parse("LIBREDDIT_DEFAULT_HIDE_HLS"),
default_hide_awards: parse("LIBREDDIT_DEFAULT_HIDE_AWARDS"),
default_hide_score: parse("LIBREDDIT_DEFAULT_HIDE_SCORE"),
default_subscriptions: parse("LIBREDDIT_DEFAULT_SUBSCRIPTIONS"),
default_disable_visit_reddit_confirmation: parse("LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION"),
banner: parse("LIBREDDIT_BANNER"),
@ -108,6 +112,7 @@ fn get_setting_from_config(name: &str, config: &Config) -> Option<String> {
"LIBREDDIT_DEFAULT_HIDE_HLS_NOTIFICATION" => config.default_hide_hls_notification.clone(),
"LIBREDDIT_DEFAULT_WIDE" => config.default_wide.clone(),
"LIBREDDIT_DEFAULT_HIDE_AWARDS" => config.default_hide_awards.clone(),
"LIBREDDIT_DEFAULT_HIDE_SCORE" => config.default_hide_score.clone(),
"LIBREDDIT_DEFAULT_SUBSCRIPTIONS" => config.default_subscriptions.clone(),
"LIBREDDIT_DEFAULT_DISABLE_VISIT_REDDIT_CONFIRMATION" => config.default_disable_visit_reddit_confirmation.clone(),
"LIBREDDIT_BANNER" => config.banner.clone(),

View file

@ -129,6 +129,7 @@ impl InstanceInfo {
container.add_table(
Table::from([
["Hide awards", &convert(&self.config.default_hide_awards)],
["Hide score", &convert(&self.config.default_hide_score)],
["Theme", &convert(&self.config.default_theme)],
["Front page", &convert(&self.config.default_front_page)],
["Layout", &convert(&self.config.default_layout)],
@ -158,6 +159,7 @@ impl InstanceInfo {
Config:\n
Banner: {:?}\n
Hide awards: {:?}\n
Hide score: {:?}\n
Default theme: {:?}\n
Default front page: {:?}\n
Default layout: {:?}\n
@ -177,6 +179,7 @@ impl InstanceInfo {
self.config.sfw_only,
self.config.banner,
self.config.default_hide_awards,
self.config.default_hide_score,
self.config.default_theme,
self.config.default_front_page,
self.config.default_layout,

View file

@ -19,7 +19,7 @@ struct SettingsTemplate {
// CONSTANTS
const PREFS: [&str; 13] = [
const PREFS: [&str; 14] = [
"theme",
"front_page",
"layout",
@ -32,6 +32,7 @@ const PREFS: [&str; 13] = [
"hide_hls_notification",
"autoplay_videos",
"hide_awards",
"hide_score",
"disable_visit_reddit_confirmation",
];

View file

@ -519,6 +519,7 @@ pub struct Preferences {
pub subscriptions: Vec<String>,
pub filters: Vec<String>,
pub hide_awards: String,
pub hide_score: String,
}
#[derive(RustEmbed)]
@ -553,6 +554,7 @@ impl Preferences {
subscriptions: setting(&req, "subscriptions").split('+').map(String::from).filter(|s| !s.is_empty()).collect(),
filters: setting(&req, "filters").split('+').map(String::from).filter(|s| !s.is_empty()).collect(),
hide_awards: setting(&req, "hide_awards"),
hide_score: setting(&req, "hide_score"),
}
}
}