mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 07:36:01 +00:00
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:
parent
9b123f45ec
commit
f9351b6512
|
@ -611,6 +611,8 @@ export async function registerUser(
|
||||||
export async function saveUserSettingsBio(api: API): Promise<LoginResponse> {
|
export async function saveUserSettingsBio(api: API): Promise<LoginResponse> {
|
||||||
let form: SaveUserSettings = {
|
let form: SaveUserSettings = {
|
||||||
show_nsfw: true,
|
show_nsfw: true,
|
||||||
|
blur_nsfw: false,
|
||||||
|
auto_expand: true,
|
||||||
theme: "darkly",
|
theme: "darkly",
|
||||||
default_sort_type: "Active",
|
default_sort_type: "Active",
|
||||||
default_listing_type: "All",
|
default_listing_type: "All",
|
||||||
|
@ -631,6 +633,8 @@ export async function saveUserSettingsFederated(
|
||||||
let bio = "a changed bio";
|
let bio = "a changed bio";
|
||||||
let form: SaveUserSettings = {
|
let form: SaveUserSettings = {
|
||||||
show_nsfw: false,
|
show_nsfw: false,
|
||||||
|
blur_nsfw: true,
|
||||||
|
auto_expand: false,
|
||||||
default_sort_type: "Hot",
|
default_sort_type: "Hot",
|
||||||
default_listing_type: "All",
|
default_listing_type: "All",
|
||||||
interface_language: "",
|
interface_language: "",
|
||||||
|
|
|
@ -124,6 +124,8 @@ impl Perform for SaveUserSettings {
|
||||||
.show_new_post_notifs(data.show_new_post_notifs)
|
.show_new_post_notifs(data.show_new_post_notifs)
|
||||||
.send_notifications_to_email(data.send_notifications_to_email)
|
.send_notifications_to_email(data.send_notifications_to_email)
|
||||||
.show_nsfw(data.show_nsfw)
|
.show_nsfw(data.show_nsfw)
|
||||||
|
.blur_nsfw(data.blur_nsfw)
|
||||||
|
.auto_expand(data.auto_expand)
|
||||||
.show_bot_accounts(data.show_bot_accounts)
|
.show_bot_accounts(data.show_bot_accounts)
|
||||||
.show_scores(data.show_scores)
|
.show_scores(data.show_scores)
|
||||||
.default_sort_type(default_sort_type)
|
.default_sort_type(default_sort_type)
|
||||||
|
|
|
@ -91,6 +91,8 @@ pub struct CaptchaResponse {
|
||||||
pub struct SaveUserSettings {
|
pub struct SaveUserSettings {
|
||||||
/// Show nsfw posts.
|
/// Show nsfw posts.
|
||||||
pub show_nsfw: Option<bool>,
|
pub show_nsfw: Option<bool>,
|
||||||
|
pub blur_nsfw: Option<bool>,
|
||||||
|
pub auto_expand: Option<bool>,
|
||||||
/// Show post and comment scores.
|
/// Show post and comment scores.
|
||||||
pub show_scores: Option<bool>,
|
pub show_scores: Option<bool>,
|
||||||
/// Your user's theme.
|
/// Your user's theme.
|
||||||
|
|
|
@ -395,6 +395,8 @@ diesel::table! {
|
||||||
totp_2fa_secret -> Nullable<Text>,
|
totp_2fa_secret -> Nullable<Text>,
|
||||||
totp_2fa_url -> Nullable<Text>,
|
totp_2fa_url -> Nullable<Text>,
|
||||||
open_links_in_new_tab -> Bool,
|
open_links_in_new_tab -> Bool,
|
||||||
|
blur_nsfw -> Bool,
|
||||||
|
auto_expand -> Bool,
|
||||||
infinite_scroll_enabled -> Bool,
|
infinite_scroll_enabled -> Bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,8 @@ pub struct LocalUser {
|
||||||
pub totp_2fa_url: Option<String>,
|
pub totp_2fa_url: Option<String>,
|
||||||
/// Open links in a new tab.
|
/// Open links in a new tab.
|
||||||
pub open_links_in_new_tab: bool,
|
pub open_links_in_new_tab: bool,
|
||||||
|
pub blur_nsfw: bool,
|
||||||
|
pub auto_expand: bool,
|
||||||
/// Whether infinite scroll is enabled.
|
/// Whether infinite scroll is enabled.
|
||||||
pub infinite_scroll_enabled: bool,
|
pub infinite_scroll_enabled: bool,
|
||||||
}
|
}
|
||||||
|
@ -83,6 +85,8 @@ pub struct LocalUserInsertForm {
|
||||||
pub totp_2fa_secret: Option<Option<String>>,
|
pub totp_2fa_secret: Option<Option<String>>,
|
||||||
pub totp_2fa_url: Option<Option<String>>,
|
pub totp_2fa_url: Option<Option<String>>,
|
||||||
pub open_links_in_new_tab: Option<bool>,
|
pub open_links_in_new_tab: Option<bool>,
|
||||||
|
pub blur_nsfw: Option<bool>,
|
||||||
|
pub auto_expand: Option<bool>,
|
||||||
pub infinite_scroll_enabled: 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_secret: Option<Option<String>>,
|
||||||
pub totp_2fa_url: Option<Option<String>>,
|
pub totp_2fa_url: Option<Option<String>>,
|
||||||
pub open_links_in_new_tab: Option<bool>,
|
pub open_links_in_new_tab: Option<bool>,
|
||||||
|
pub blur_nsfw: Option<bool>,
|
||||||
|
pub auto_expand: Option<bool>,
|
||||||
pub infinite_scroll_enabled: Option<bool>,
|
pub infinite_scroll_enabled: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,6 +280,8 @@ mod tests {
|
||||||
person_id: inserted_sara_local_user.person_id,
|
person_id: inserted_sara_local_user.person_id,
|
||||||
email: inserted_sara_local_user.email,
|
email: inserted_sara_local_user.email,
|
||||||
show_nsfw: inserted_sara_local_user.show_nsfw,
|
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,
|
theme: inserted_sara_local_user.theme,
|
||||||
default_sort_type: inserted_sara_local_user.default_sort_type,
|
default_sort_type: inserted_sara_local_user.default_sort_type,
|
||||||
default_listing_type: inserted_sara_local_user.default_listing_type,
|
default_listing_type: inserted_sara_local_user.default_listing_type,
|
||||||
|
|
2
migrations/2023-06-27-065106_add_ui_settings/down.sql
Normal file
2
migrations/2023-06-27-065106_add_ui_settings/down.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
alter table local_user drop column blur_nsfw;
|
||||||
|
alter table local_user drop column auto_expand;
|
6
migrations/2023-06-27-065106_add_ui_settings/up.sql
Normal file
6
migrations/2023-06-27-065106_add_ui_settings/up.sql
Normal 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;
|
Loading…
Reference in a new issue