From: Simon Bordeyne Date: Wed, 12 Jul 2023 13:12:01 +0000 (+0200) Subject: Add infinite scroll user option (#3572) X-Git-Url: http://these/git/%7BtotpUrl%7D?a=commitdiff_plain;h=9b5e765364ecf7de64c9cbc7a452ccfaabce5449;p=lemmy.git Add infinite scroll user option (#3572) --- diff --git a/crates/api/src/local_user/save_settings.rs b/crates/api/src/local_user/save_settings.rs index 822f08d2..4176a3f4 100644 --- a/crates/api/src/local_user/save_settings.rs +++ b/crates/api/src/local_user/save_settings.rs @@ -133,6 +133,7 @@ impl Perform for SaveUserSettings { .totp_2fa_secret(totp_2fa_secret) .totp_2fa_url(totp_2fa_url) .open_links_in_new_tab(data.open_links_in_new_tab) + .infinite_scroll_enabled(data.infinite_scroll_enabled) .build(); let local_user_res = diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index 824d132a..031bc6c7 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -133,6 +133,8 @@ pub struct SaveUserSettings { pub auth: Sensitive, /// Open links in a new tab pub open_links_in_new_tab: Option, + /// Enable infinite scroll + pub infinite_scroll_enabled: Option, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 01aafa1d..e503a827 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -407,6 +407,7 @@ diesel::table! { totp_2fa_secret -> Nullable, totp_2fa_url -> Nullable, open_links_in_new_tab -> Bool, + infinite_scroll_enabled -> Bool, } } diff --git a/crates/db_schema/src/source/local_user.rs b/crates/db_schema/src/source/local_user.rs index d6c99971..d9e1bde7 100644 --- a/crates/db_schema/src/source/local_user.rs +++ b/crates/db_schema/src/source/local_user.rs @@ -53,6 +53,8 @@ pub struct LocalUser { pub totp_2fa_url: Option, /// Open links in a new tab. pub open_links_in_new_tab: bool, + /// Whether infinite scroll is enabled. + pub infinite_scroll_enabled: bool, } #[derive(Clone, TypedBuilder)] @@ -81,6 +83,7 @@ pub struct LocalUserInsertForm { pub totp_2fa_secret: Option>, pub totp_2fa_url: Option>, pub open_links_in_new_tab: Option, + pub infinite_scroll_enabled: Option, } #[derive(Clone, TypedBuilder)] @@ -106,4 +109,5 @@ pub struct LocalUserUpdateForm { pub totp_2fa_secret: Option>, pub totp_2fa_url: Option>, pub open_links_in_new_tab: Option, + pub infinite_scroll_enabled: Option, } diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index ad6a7e9d..a2fdcba6 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -295,6 +295,7 @@ mod tests { totp_2fa_url: inserted_sara_local_user.totp_2fa_url, password_encrypted: inserted_sara_local_user.password_encrypted, open_links_in_new_tab: inserted_sara_local_user.open_links_in_new_tab, + infinite_scroll_enabled: inserted_sara_local_user.infinite_scroll_enabled, }, creator: Person { id: inserted_sara_person.id, diff --git a/migrations/2023-07-10-075550_add-infinite-scroll-setting/down.sql b/migrations/2023-07-10-075550_add-infinite-scroll-setting/down.sql new file mode 100644 index 00000000..66ff507d --- /dev/null +++ b/migrations/2023-07-10-075550_add-infinite-scroll-setting/down.sql @@ -0,0 +1 @@ +alter table local_user drop column infinite_scroll_enabled; diff --git a/migrations/2023-07-10-075550_add-infinite-scroll-setting/up.sql b/migrations/2023-07-10-075550_add-infinite-scroll-setting/up.sql new file mode 100644 index 00000000..905bc710 --- /dev/null +++ b/migrations/2023-07-10-075550_add-infinite-scroll-setting/up.sql @@ -0,0 +1 @@ +alter table local_user add column infinite_scroll_enabled boolean default false not null;