UI Settings - Blur NSFW & Auto Expand (#3377)

* 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>
This commit is contained in:
Domenic Horner 2023-07-26 19:53:45 +08:00 committed by GitHub
parent 9b123f45ec
commit f9351b6512
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 0 deletions

View 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: "",

View 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)

View 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.

View 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,
}
}

View 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>,
}

View 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,

View file

@ -0,0 +1,2 @@
alter table local_user drop column blur_nsfw;
alter table local_user drop column auto_expand;

View file

@ -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;