]> Untitled Git - lemmy.git/blobdiff - crates/api/src/local_user/save_settings.rs
Add infinite scroll user option (#3572)
[lemmy.git] / crates / api / src / local_user / save_settings.rs
index 578d177323322c233d3261a26045b2595bd4c0ba..4176a3f4c511014b0d959d43609b4bf12cdd28d3 100644 (file)
@@ -35,7 +35,7 @@ impl Perform for SaveUserSettings {
   async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> {
     let data: &SaveUserSettings = self;
     let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
-    let site_view = SiteView::read_local(context.pool()).await?;
+    let site_view = SiteView::read_local(&mut context.pool()).await?;
 
     let avatar = diesel_option_overwrite_to_url(&data.avatar)?;
     let banner = diesel_option_overwrite_to_url(&data.banner)?;
@@ -49,8 +49,13 @@ impl Perform for SaveUserSettings {
       let previous_email = local_user_view.local_user.email.clone().unwrap_or_default();
       // Only send the verification email if there was an email change
       if previous_email.ne(email) {
-        send_verification_email(&local_user_view, email, context.pool(), context.settings())
-          .await?;
+        send_verification_email(
+          &local_user_view,
+          email,
+          &mut context.pool(),
+          context.settings(),
+        )
+        .await?;
       }
     }
 
@@ -90,12 +95,12 @@ impl Perform for SaveUserSettings {
       .banner(banner)
       .build();
 
-    Person::update(context.pool(), person_id, &person_form)
+    Person::update(&mut context.pool(), person_id, &person_form)
       .await
       .with_lemmy_type(LemmyErrorType::UserAlreadyExists)?;
 
     if let Some(discussion_languages) = data.discussion_languages.clone() {
-      LocalUserLanguage::update(context.pool(), discussion_languages, local_user_id).await?;
+      LocalUserLanguage::update(&mut context.pool(), discussion_languages, local_user_id).await?;
     }
 
     // If generate_totp is Some(false), this will clear it out from the database.
@@ -128,9 +133,11 @@ 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 = LocalUser::update(context.pool(), local_user_id, &local_user_form).await;
+    let local_user_res =
+      LocalUser::update(&mut context.pool(), local_user_id, &local_user_form).await;
     let updated_local_user = match local_user_res {
       Ok(u) => u,
       Err(e) => {