]> Untitled Git - lemmy.git/commitdiff
Adding a setting to show / hide scores. Fixes #1503
authorDessalines <tyhou13@gmx.com>
Wed, 31 Mar 2021 10:54:46 +0000 (06:54 -0400)
committerDessalines <tyhou13@gmx.com>
Wed, 31 Mar 2021 10:54:46 +0000 (06:54 -0400)
crates/api/src/local_user.rs
crates/api_common/src/person.rs
crates/api_crud/src/user/create.rs
crates/db_queries/src/source/local_user.rs
crates/db_schema/src/schema.rs
crates/db_schema/src/source/local_user.rs
migrations/2021-03-31-103917_add_show_score_setting/down.sql [new file with mode: 0644]
migrations/2021-03-31-103917_add_show_score_setting/up.sql [new file with mode: 0644]

index 656ddf9719fec29b859659f04cae6be112228143..c28d8c725c730e1e95f71e4171aef2f7e379c759 100644 (file)
@@ -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,
index 7767da460d82e118f7b21c51774eb0fcf6e2aad9..c4f8adbf931c463c9184127648f0598bb8ce5337 100644 (file)
@@ -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,
 }
index 63a6474d62484b4a312ed8287992a8cd36211b3d..c61c1e79a6663b63626194d5b84e2bf92fb73d39 100644 (file)
@@ -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),
     };
 
index 18720ceba3c0a95469955558a9d271817c5e86d7..d1fad2e8523ff8c8566c49ee0ff6497a29ff2bd8 100644 (file)
@@ -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,
       )
     }
   }
index 5bc55f529bc6a63fb620d545e93c4640959990c8..a99908ad3ed8a98505af81b593f6562fb3c3a34a 100644 (file)
@@ -154,6 +154,7 @@ table! {
         show_avatars -> Bool,
         send_notifications_to_email -> Bool,
         validator_time -> Timestamp,
+        show_scores -> Bool,
     }
 }
 
index 6f28a8fbcdba6e4e1c44d0f1696ec0684291aaa7..0a7181fdbef57d36bade01a67d46c8808d9e1dd4 100644 (file)
@@ -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 (file)
index 0000000..9d35b56
--- /dev/null
@@ -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 (file)
index 0000000..7960886
--- /dev/null
@@ -0,0 +1 @@
+alter table local_user add column show_scores boolean default true not null;