From cf1c32d2abe5b4083bfd413e369053f0bcbff8c8 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Tue, 17 Oct 2023 14:52:34 +0000 Subject: [PATCH] Enable animated avatars setting (#4040) * feat: Add user setting for toggling avatar gif animations * Add forgotten post listing mode option to settings form * Fix compilation error * Fix formatting * Change name of column to be more general purpose * Fix sql format. * Fix comments * Running format. --------- Co-authored-by: Dessalines Co-authored-by: Dessalines --- crates/api/src/local_user/save_settings.rs | 3 +++ crates/api_common/src/person.rs | 4 ++++ 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 + crates/utils/translations | 2 +- migrations/2023-10-13-175712_allow_animated_avatars/down.sql | 3 +++ migrations/2023-10-13-175712_allow_animated_avatars/up.sql | 3 +++ 8 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 migrations/2023-10-13-175712_allow_animated_avatars/down.sql create mode 100644 migrations/2023-10-13-175712_allow_animated_avatars/up.sql diff --git a/crates/api/src/local_user/save_settings.rs b/crates/api/src/local_user/save_settings.rs index d219416f8..90f6b6dd8 100644 --- a/crates/api/src/local_user/save_settings.rs +++ b/crates/api/src/local_user/save_settings.rs @@ -114,6 +114,9 @@ pub async fn save_user_settings( interface_language: data.interface_language.clone(), open_links_in_new_tab: data.open_links_in_new_tab, infinite_scroll_enabled: data.infinite_scroll_enabled, + post_listing_mode: data.post_listing_mode, + enable_keyboard_navigation: data.enable_keyboard_navigation, + enable_animated_images: data.enable_animated_images, ..Default::default() }; diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index c410cbbe8..c067c3799 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -3,6 +3,7 @@ use lemmy_db_schema::{ newtypes::{CommentReplyId, CommunityId, LanguageId, PersonId, PersonMentionId}, CommentSortType, ListingType, + PostListingMode, SortType, }; use lemmy_db_views::structs::{CommentView, PostView}; @@ -123,8 +124,11 @@ pub struct SaveUserSettings { pub open_links_in_new_tab: Option, /// Enable infinite scroll pub infinite_scroll_enabled: Option, + pub post_listing_mode: Option, /// Whether to allow keyboard navigation (for browsing and interacting with posts and comments). pub enable_keyboard_navigation: Option, + /// Whether user avatars or inline images in the UI that are gifs should be allowed to play or should be paused + pub enable_animated_images: Option, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 6942fdccd..2d6f221fc 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -444,6 +444,7 @@ diesel::table! { post_listing_mode -> PostListingModeEnum, totp_2fa_enabled -> Bool, enable_keyboard_navigation -> Bool, + enable_animated_images -> Bool, } } diff --git a/crates/db_schema/src/source/local_user.rs b/crates/db_schema/src/source/local_user.rs index 220593698..08f78bbb8 100644 --- a/crates/db_schema/src/source/local_user.rs +++ b/crates/db_schema/src/source/local_user.rs @@ -58,6 +58,8 @@ pub struct LocalUser { pub totp_2fa_enabled: bool, /// Whether to allow keyboard navigation (for browsing and interacting with posts and comments). pub enable_keyboard_navigation: bool, + /// Whether user avatars and inline images in the UI that are gifs should be allowed to play or should be paused + pub enable_animated_images: bool, } #[derive(Clone, TypedBuilder)] @@ -91,6 +93,7 @@ pub struct LocalUserInsertForm { pub post_listing_mode: Option, pub totp_2fa_enabled: Option, pub enable_keyboard_navigation: Option, + pub enable_animated_images: Option, } #[derive(Clone, Default)] @@ -120,4 +123,5 @@ pub struct LocalUserUpdateForm { pub post_listing_mode: Option, pub totp_2fa_enabled: Option, pub enable_keyboard_navigation: Option, + pub enable_animated_images: Option, } diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index c2d49207a..0bdd50cf1 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -267,6 +267,7 @@ mod tests { post_listing_mode: inserted_sara_local_user.post_listing_mode, totp_2fa_enabled: inserted_sara_local_user.totp_2fa_enabled, enable_keyboard_navigation: inserted_sara_local_user.enable_keyboard_navigation, + enable_animated_images: inserted_sara_local_user.enable_animated_images, }, creator: Person { id: inserted_sara_person.id, diff --git a/crates/utils/translations b/crates/utils/translations index e943f97fe..d0f354837 160000 --- a/crates/utils/translations +++ b/crates/utils/translations @@ -1 +1 @@ -Subproject commit e943f97fe481dc425acdebc8872bf1fdcabaf875 +Subproject commit d0f3548379e446d2c333e582734bc68f8d684f4d diff --git a/migrations/2023-10-13-175712_allow_animated_avatars/down.sql b/migrations/2023-10-13-175712_allow_animated_avatars/down.sql new file mode 100644 index 000000000..43543c9bf --- /dev/null +++ b/migrations/2023-10-13-175712_allow_animated_avatars/down.sql @@ -0,0 +1,3 @@ +ALTER TABLE local_user + DROP COLUMN enable_animated_images; + diff --git a/migrations/2023-10-13-175712_allow_animated_avatars/up.sql b/migrations/2023-10-13-175712_allow_animated_avatars/up.sql new file mode 100644 index 000000000..d36d22994 --- /dev/null +++ b/migrations/2023-10-13-175712_allow_animated_avatars/up.sql @@ -0,0 +1,3 @@ +ALTER TABLE local_user + ADD COLUMN enable_animated_images boolean DEFAULT TRUE NOT NULL; +