From: Dessalines <tyhou13@gmx.com>
Date: Wed, 31 Mar 2021 10:54:46 +0000 (-0400)
Subject: Adding a setting to show / hide scores. Fixes #1503
X-Git-Url: http://these/git/%22https:/join-lemmy.org/readmes/static/%24%7Bargs.pageFn.prev%7D?a=commitdiff_plain;h=2f63fdbde09d57ebbf2e891fe009d35f60847ac6;p=lemmy.git

Adding a setting to show / hide scores. Fixes #1503
---

diff --git a/crates/api/src/local_user.rs b/crates/api/src/local_user.rs
index 656ddf97..c28d8c72 100644
--- a/crates/api/src/local_user.rs
+++ b/crates/api/src/local_user.rs
@@ -267,6 +267,7 @@ impl Perform for SaveUserSettings {
       email,
       password_encrypted,
       show_nsfw: data.show_nsfw,
+      show_scores: data.show_scores,
       theme: data.theme.to_owned(),
       default_sort_type,
       default_listing_type,
diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs
index 7767da46..c4f8adbf 100644
--- a/crates/api_common/src/person.rs
+++ b/crates/api_common/src/person.rs
@@ -47,6 +47,8 @@ pub struct CaptchaResponse {
 #[derive(Deserialize)]
 pub struct SaveUserSettings {
   pub show_nsfw: Option<bool>,
+  pub show_scores: Option<bool>,
+  pub show_avatars: Option<bool>,
   pub theme: Option<String>,
   pub default_sort_type: Option<i16>,
   pub default_listing_type: Option<i16>,
@@ -60,7 +62,6 @@ pub struct SaveUserSettings {
   pub new_password: Option<String>,
   pub new_password_verify: Option<String>,
   pub old_password: Option<String>,
-  pub show_avatars: Option<bool>,
   pub send_notifications_to_email: Option<bool>,
   pub auth: String,
 }
diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs
index 63a6474d..c61c1e79 100644
--- a/crates/api_crud/src/user/create.rs
+++ b/crates/api_crud/src/user/create.rs
@@ -133,6 +133,7 @@ impl PerformCrud for Register {
       default_listing_type: Some(ListingType::Subscribed as i16),
       lang: Some("browser".into()),
       show_avatars: Some(true),
+      show_scores: Some(true),
       send_notifications_to_email: Some(false),
     };
 
diff --git a/crates/db_queries/src/source/local_user.rs b/crates/db_queries/src/source/local_user.rs
index 18720ceb..d1fad2e8 100644
--- a/crates/db_queries/src/source/local_user.rs
+++ b/crates/db_queries/src/source/local_user.rs
@@ -24,6 +24,7 @@ mod safe_settings_type {
     show_avatars,
     send_notifications_to_email,
     validator_time,
+    show_scores,
   );
 
   impl ToSafeSettings for LocalUser {
@@ -43,6 +44,7 @@ mod safe_settings_type {
         show_avatars,
         send_notifications_to_email,
         validator_time,
+        show_scores,
       )
     }
   }
diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs
index 5bc55f52..a99908ad 100644
--- a/crates/db_schema/src/schema.rs
+++ b/crates/db_schema/src/schema.rs
@@ -154,6 +154,7 @@ table! {
         show_avatars -> Bool,
         send_notifications_to_email -> Bool,
         validator_time -> Timestamp,
+        show_scores -> Bool,
     }
 }
 
diff --git a/crates/db_schema/src/source/local_user.rs b/crates/db_schema/src/source/local_user.rs
index 6f28a8fb..0a7181fd 100644
--- a/crates/db_schema/src/source/local_user.rs
+++ b/crates/db_schema/src/source/local_user.rs
@@ -16,6 +16,7 @@ pub struct LocalUser {
   pub show_avatars: bool,
   pub send_notifications_to_email: bool,
   pub validator_time: chrono::NaiveDateTime,
+  pub show_scores: bool,
 }
 
 // TODO redo these, check table defaults
@@ -32,6 +33,7 @@ pub struct LocalUserForm {
   pub lang: Option<String>,
   pub show_avatars: Option<bool>,
   pub send_notifications_to_email: Option<bool>,
+  pub show_scores: Option<bool>,
 }
 
 /// A local user view that removes password encrypted
@@ -49,4 +51,5 @@ pub struct LocalUserSettings {
   pub show_avatars: bool,
   pub send_notifications_to_email: bool,
   pub validator_time: chrono::NaiveDateTime,
+  pub show_scores: bool,
 }
diff --git a/migrations/2021-03-31-103917_add_show_score_setting/down.sql b/migrations/2021-03-31-103917_add_show_score_setting/down.sql
new file mode 100644
index 00000000..9d35b563
--- /dev/null
+++ b/migrations/2021-03-31-103917_add_show_score_setting/down.sql
@@ -0,0 +1 @@
+alter table local_user drop column show_scores;
diff --git a/migrations/2021-03-31-103917_add_show_score_setting/up.sql b/migrations/2021-03-31-103917_add_show_score_setting/up.sql
new file mode 100644
index 00000000..7960886a
--- /dev/null
+++ b/migrations/2021-03-31-103917_add_show_score_setting/up.sql
@@ -0,0 +1 @@
+alter table local_user add column show_scores boolean default true not null;