]> Untitled Git - lemmy.git/commitdiff
Add infinite scroll user option (#3572)
authorSimon Bordeyne <Dogeek@users.noreply.github.com>
Wed, 12 Jul 2023 13:12:01 +0000 (15:12 +0200)
committerGitHub <noreply@github.com>
Wed, 12 Jul 2023 13:12:01 +0000 (09:12 -0400)
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-07-10-075550_add-infinite-scroll-setting/down.sql [new file with mode: 0644]
migrations/2023-07-10-075550_add-infinite-scroll-setting/up.sql [new file with mode: 0644]

index 822f08d2819b9dd64f476818456083ff15826add..4176a3f4c511014b0d959d43609b4bf12cdd28d3 100644 (file)
@@ -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 =
index 824d132a562029bdd81ec7161ccf0539666637ce..031bc6c7e88cba34f6ceb1b07cab686857ce0466 100644 (file)
@@ -133,6 +133,8 @@ pub struct SaveUserSettings {
   pub auth: Sensitive<String>,
   /// Open links in a new tab
   pub open_links_in_new_tab: Option<bool>,
+  /// Enable infinite scroll
+  pub infinite_scroll_enabled: Option<bool>,
 }
 
 #[derive(Debug, Serialize, Deserialize, Clone, Default)]
index 01aafa1d215034411a0bd213bc27bf148f6e0ee5..e503a827467df50692f92113e6427873452a8ede 100644 (file)
@@ -407,6 +407,7 @@ diesel::table! {
         totp_2fa_secret -> Nullable<Text>,
         totp_2fa_url -> Nullable<Text>,
         open_links_in_new_tab -> Bool,
+        infinite_scroll_enabled -> Bool,
     }
 }
 
index d6c9997131c446ef7486af426e159427d745d6e2..d9e1bde756910bbbcbf3599866070651e1583ea4 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,
+  /// 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<Option<String>>,
   pub totp_2fa_url: Option<Option<String>>,
   pub open_links_in_new_tab: Option<bool>,
+  pub infinite_scroll_enabled: Option<bool>,
 }
 
 #[derive(Clone, TypedBuilder)]
@@ -106,4 +109,5 @@ 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 infinite_scroll_enabled: Option<bool>,
 }
index ad6a7e9d34d908bfdf9d050d992f6ba7ffa775ed..a2fdcba60973a68ade1acd6b78214ec9953b6b50 100644 (file)
@@ -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 (file)
index 0000000..66ff507
--- /dev/null
@@ -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 (file)
index 0000000..905bc71
--- /dev/null
@@ -0,0 +1 @@
+alter table local_user add column infinite_scroll_enabled boolean default false not null;