]> Untitled Git - lemmy.git/commitdiff
UI Settings - Blur NSFW & Auto Expand (#3377)
authorDomenic Horner <domenic@tgxn.net>
Wed, 26 Jul 2023 11:53:45 +0000 (19:53 +0800)
committerGitHub <noreply@github.com>
Wed, 26 Jul 2023 11:53:45 +0000 (07:53 -0400)
* add new flag to api

* add new ui settings for local user

* remove extraneous def

* add props to application reg.

* fix clippy updated these

* re-order db schema entries

* remove dupe

* update lemmy sdk

* update lemmy js client

---------

Co-authored-by: Nutomic <me@nutomic.com>
api_tests/src/shared.ts
crates/api/src/local_user/save_settings.rs
crates/api_common/src/person.rs
crates/db_schema/src/schema.rs
crates/db_schema/src/source/local_user.rs
crates/db_views/src/registration_application_view.rs
migrations/2023-06-27-065106_add_ui_settings/down.sql [new file with mode: 0644]
migrations/2023-06-27-065106_add_ui_settings/up.sql [new file with mode: 0644]

index bbd4eaaeb2c40345932bc70dca6df5bd64b3aa90..e4306c94c0de6d94b22b83987aa0ffea7e1d64a8 100644 (file)
@@ -611,6 +611,8 @@ export async function registerUser(
 export async function saveUserSettingsBio(api: API): Promise<LoginResponse> {
   let form: SaveUserSettings = {
     show_nsfw: true,
+    blur_nsfw: false,
+    auto_expand: true,
     theme: "darkly",
     default_sort_type: "Active",
     default_listing_type: "All",
@@ -631,6 +633,8 @@ export async function saveUserSettingsFederated(
   let bio = "a changed bio";
   let form: SaveUserSettings = {
     show_nsfw: false,
+    blur_nsfw: true,
+    auto_expand: false,
     default_sort_type: "Hot",
     default_listing_type: "All",
     interface_language: "",
index 4176a3f4c511014b0d959d43609b4bf12cdd28d3..c5038eb7982a6e104f4e91fa8b0f7d45e59f13d8 100644 (file)
@@ -124,6 +124,8 @@ impl Perform for SaveUserSettings {
       .show_new_post_notifs(data.show_new_post_notifs)
       .send_notifications_to_email(data.send_notifications_to_email)
       .show_nsfw(data.show_nsfw)
+      .blur_nsfw(data.blur_nsfw)
+      .auto_expand(data.auto_expand)
       .show_bot_accounts(data.show_bot_accounts)
       .show_scores(data.show_scores)
       .default_sort_type(default_sort_type)
index 031bc6c7e88cba34f6ceb1b07cab686857ce0466..79a0aa377a084c5c2a53898326a7d55c043b52db 100644 (file)
@@ -91,6 +91,8 @@ pub struct CaptchaResponse {
 pub struct SaveUserSettings {
   /// Show nsfw posts.
   pub show_nsfw: Option<bool>,
+  pub blur_nsfw: Option<bool>,
+  pub auto_expand: Option<bool>,
   /// Show post and comment scores.
   pub show_scores: Option<bool>,
   /// Your user's theme.
index 17a0f99f8e59228d05122a8026fc26ee07bc9f2e..faebe9999f42394a24f64b3a3959b73723d675e1 100644 (file)
@@ -395,6 +395,8 @@ diesel::table! {
         totp_2fa_secret -> Nullable<Text>,
         totp_2fa_url -> Nullable<Text>,
         open_links_in_new_tab -> Bool,
+        blur_nsfw -> Bool,
+        auto_expand -> Bool,
         infinite_scroll_enabled -> Bool,
     }
 }
index d9e1bde756910bbbcbf3599866070651e1583ea4..0d8db6693f0b90f3914e44f3370d87e5f87030c6 100644 (file)
@@ -53,6 +53,8 @@ pub struct LocalUser {
   pub totp_2fa_url: Option<String>,
   /// Open links in a new tab.
   pub open_links_in_new_tab: bool,
+  pub blur_nsfw: bool,
+  pub auto_expand: bool,
   /// Whether infinite scroll is enabled.
   pub infinite_scroll_enabled: bool,
 }
@@ -83,6 +85,8 @@ pub struct LocalUserInsertForm {
   pub totp_2fa_secret: Option<Option<String>>,
   pub totp_2fa_url: Option<Option<String>>,
   pub open_links_in_new_tab: Option<bool>,
+  pub blur_nsfw: Option<bool>,
+  pub auto_expand: Option<bool>,
   pub infinite_scroll_enabled: Option<bool>,
 }
 
@@ -109,5 +113,7 @@ pub struct LocalUserUpdateForm {
   pub totp_2fa_secret: Option<Option<String>>,
   pub totp_2fa_url: Option<Option<String>>,
   pub open_links_in_new_tab: Option<bool>,
+  pub blur_nsfw: Option<bool>,
+  pub auto_expand: Option<bool>,
   pub infinite_scroll_enabled: Option<bool>,
 }
index 106e41e433fb316151302508a48ee562e975abb4..8e2f5826405edc7aa0f323e79797534c90d5b90a 100644 (file)
@@ -280,6 +280,8 @@ mod tests {
         person_id: inserted_sara_local_user.person_id,
         email: inserted_sara_local_user.email,
         show_nsfw: inserted_sara_local_user.show_nsfw,
+        auto_expand: inserted_sara_local_user.auto_expand,
+        blur_nsfw: inserted_sara_local_user.blur_nsfw,
         theme: inserted_sara_local_user.theme,
         default_sort_type: inserted_sara_local_user.default_sort_type,
         default_listing_type: inserted_sara_local_user.default_listing_type,
diff --git a/migrations/2023-06-27-065106_add_ui_settings/down.sql b/migrations/2023-06-27-065106_add_ui_settings/down.sql
new file mode 100644 (file)
index 0000000..51fa704
--- /dev/null
@@ -0,0 +1,2 @@
+alter table local_user drop column blur_nsfw;
+alter table local_user drop column auto_expand;
diff --git a/migrations/2023-06-27-065106_add_ui_settings/up.sql b/migrations/2023-06-27-065106_add_ui_settings/up.sql
new file mode 100644 (file)
index 0000000..3c66c9c
--- /dev/null
@@ -0,0 +1,6 @@
+
+-- Add the blur_nsfw to the local user table as a setting
+alter table local_user add column blur_nsfw boolean not null default true;
+
+-- Add the auto_expand to the local user table as a setting
+alter table local_user add column auto_expand boolean not null default false;