replace auto_expand_images with default_site_post_listing_mode

lemmynsfw-changes
Felix Ableitner 2024-01-24 11:41:27 +01:00
parent 23384e133b
commit a4a4693f1a
8 changed files with 19 additions and 13 deletions

View File

@ -10,6 +10,7 @@ use lemmy_db_schema::{
}, },
ListingType, ListingType,
ModlogActionType, ModlogActionType,
PostListingMode,
RegistrationMode, RegistrationMode,
SearchType, SearchType,
SortType, SortType,
@ -188,7 +189,7 @@ pub struct CreateSite {
pub taglines: Option<Vec<String>>, pub taglines: Option<Vec<String>>,
pub registration_mode: Option<RegistrationMode>, pub registration_mode: Option<RegistrationMode>,
pub content_warning: Option<String>, pub content_warning: Option<String>,
pub auto_expand_images: Option<bool>, pub default_post_listing_mode: Option<PostListingMode>,
} }
#[skip_serializing_none] #[skip_serializing_none]
@ -270,8 +271,8 @@ pub struct EditSite {
/// If present, nsfw content is visible by default. Should be displayed by frontends/clients /// If present, nsfw content is visible by default. Should be displayed by frontends/clients
/// when the site is first opened by a user. /// when the site is first opened by a user.
pub content_warning: Option<String>, pub content_warning: Option<String>,
/// Automatically expand images to full size in the website without manual user action /// Default value for [LocalUser.post_listing_mode]
pub auto_expand_images: Option<bool>, pub default_post_listing_mode: Option<PostListingMode>,
} }
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]

View File

@ -90,7 +90,7 @@ pub async fn create_site(
captcha_enabled: data.captcha_enabled, captcha_enabled: data.captcha_enabled,
captcha_difficulty: data.captcha_difficulty.clone(), captcha_difficulty: data.captcha_difficulty.clone(),
content_warning: diesel_option_overwrite(data.content_warning.clone()), content_warning: diesel_option_overwrite(data.content_warning.clone()),
auto_expand_images: data.auto_expand_images, default_post_listing_mode: data.default_post_listing_mode,
..Default::default() ..Default::default()
}; };

View File

@ -91,7 +91,7 @@ pub async fn update_site(
captcha_difficulty: data.captcha_difficulty.clone(), captcha_difficulty: data.captcha_difficulty.clone(),
reports_email_admins: data.reports_email_admins, reports_email_admins: data.reports_email_admins,
content_warning: diesel_option_overwrite(data.content_warning.clone()), content_warning: diesel_option_overwrite(data.content_warning.clone()),
auto_expand_images: data.auto_expand_images, default_post_listing_mode: data.default_post_listing_mode,
..Default::default() ..Default::default()
}; };

View File

@ -139,7 +139,9 @@ pub enum RegistrationMode {
Open, Open,
} }
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)] #[derive(
EnumString, Display, Debug, Serialize, Deserialize, Default, Clone, Copy, PartialEq, Eq,
)]
#[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr(feature = "full", derive(DbEnum, TS))]
#[cfg_attr( #[cfg_attr(
feature = "full", feature = "full",
@ -150,6 +152,7 @@ pub enum RegistrationMode {
/// A post-view mode that changes how multiple post listings look. /// A post-view mode that changes how multiple post listings look.
pub enum PostListingMode { pub enum PostListingMode {
/// A compact, list-type view. /// A compact, list-type view.
#[default]
List, List,
/// A larger card-type view. /// A larger card-type view.
Card, Card,

View File

@ -345,6 +345,7 @@ diesel::table! {
use diesel::sql_types::*; use diesel::sql_types::*;
use super::sql_types::ListingTypeEnum; use super::sql_types::ListingTypeEnum;
use super::sql_types::RegistrationModeEnum; use super::sql_types::RegistrationModeEnum;
use super::sql_types::PostListingModeEnum;
local_site (id) { local_site (id) {
id -> Int4, id -> Int4,
@ -373,7 +374,7 @@ diesel::table! {
reports_email_admins -> Bool, reports_email_admins -> Bool,
federation_signed_fetch -> Bool, federation_signed_fetch -> Bool,
content_warning -> Nullable<Text>, content_warning -> Nullable<Text>,
auto_expand_images -> Bool, default_post_listing_mode -> PostListingModeEnum,
} }
} }

View File

@ -3,6 +3,7 @@ use crate::schema::local_site;
use crate::{ use crate::{
newtypes::{LocalSiteId, SiteId}, newtypes::{LocalSiteId, SiteId},
ListingType, ListingType,
PostListingMode,
RegistrationMode, RegistrationMode,
}; };
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
@ -67,8 +68,8 @@ pub struct LocalSite {
/// If present, nsfw content is visible by default. Should be displayed by frontends/clients /// If present, nsfw content is visible by default. Should be displayed by frontends/clients
/// when the site is first opened by a user. /// when the site is first opened by a user.
pub content_warning: Option<String>, pub content_warning: Option<String>,
/// Automatically expand images to full size in the website without manual user action /// Default value for [LocalUser.post_listing_mode]
pub auto_expand_images: bool, pub default_post_listing_mode: PostListingMode,
} }
#[derive(Clone, TypedBuilder)] #[derive(Clone, TypedBuilder)]
@ -99,7 +100,7 @@ pub struct LocalSiteInsertForm {
pub reports_email_admins: Option<bool>, pub reports_email_admins: Option<bool>,
pub federation_signed_fetch: Option<bool>, pub federation_signed_fetch: Option<bool>,
pub content_warning: Option<String>, pub content_warning: Option<String>,
pub auto_expand_images: Option<bool>, pub default_post_listing_mode: Option<PostListingMode>,
} }
#[derive(Clone, Default)] #[derive(Clone, Default)]
@ -128,5 +129,5 @@ pub struct LocalSiteUpdateForm {
pub updated: Option<Option<DateTime<Utc>>>, pub updated: Option<Option<DateTime<Utc>>>,
pub federation_signed_fetch: Option<bool>, pub federation_signed_fetch: Option<bool>,
pub content_warning: Option<Option<String>>, pub content_warning: Option<Option<String>>,
pub auto_expand_images: Option<bool>, pub default_post_listing_mode: Option<PostListingMode>,
} }

View File

@ -2,7 +2,7 @@ ALTER TABLE local_site
DROP COLUMN content_warning; DROP COLUMN content_warning;
ALTER TABLE local_site ALTER TABLE local_site
DROP COLUMN auto_expand_images; DROP COLUMN default_post_listing_mode;
ALTER TABLE community ALTER TABLE community
DROP COLUMN only_followers_can_vote; DROP COLUMN only_followers_can_vote;

View File

@ -2,7 +2,7 @@ ALTER TABLE local_site
ADD COLUMN content_warning text; ADD COLUMN content_warning text;
ALTER TABLE local_site ALTER TABLE local_site
ADD COLUMN auto_expand_images boolean NOT NULL DEFAULT FALSE; ADD COLUMN default_post_listing_mode post_listing_mode_enum NOT NULL DEFAULT 'List';
ALTER TABLE community ALTER TABLE community
ADD COLUMN only_followers_can_vote boolean NOT NULL DEFAULT FALSE; ADD COLUMN only_followers_can_vote boolean NOT NULL DEFAULT FALSE;