From 9b5e765364ecf7de64c9cbc7a452ccfaabce5449 Mon Sep 17 00:00:00 2001 From: Simon Bordeyne Date: Wed, 12 Jul 2023 15:12:01 +0200 Subject: [PATCH] Add infinite scroll user option (#3572) --- crates/api/src/local_user/save_settings.rs | 1 + crates/api_common/src/person.rs | 2 ++ crates/db_schema/src/schema.rs | 1 + crates/db_schema/src/source/local_user.rs | 4 ++++ crates/db_views/src/registration_application_view.rs | 1 + .../2023-07-10-075550_add-infinite-scroll-setting/down.sql | 1 + .../2023-07-10-075550_add-infinite-scroll-setting/up.sql | 1 + 7 files changed, 11 insertions(+) create mode 100644 migrations/2023-07-10-075550_add-infinite-scroll-setting/down.sql create mode 100644 migrations/2023-07-10-075550_add-infinite-scroll-setting/up.sql diff --git a/crates/api/src/local_user/save_settings.rs b/crates/api/src/local_user/save_settings.rs index 822f08d28..4176a3f4c 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 824d132a5..031bc6c7e 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 01aafa1d2..e503a8274 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 d6c999713..d9e1bde75 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 ad6a7e9d3..a2fdcba60 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 000000000..66ff507d9 --- /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 000000000..905bc7109 --- /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;