Skip to content

Commit

Permalink
Addressing PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines authored and Nutomic committed Aug 9, 2023
1 parent a9e53db commit e351d49
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 93 deletions.
4 changes: 2 additions & 2 deletions crates/db_schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ pub enum RegistrationMode {
#[cfg_attr(feature = "full", derive(DbEnum, TS))]
#[cfg_attr(
feature = "full",
ExistingTypePath = "crate::schema::sql_types::PostViewModeEnum"
ExistingTypePath = "crate::schema::sql_types::PostListingModeEnum"
)]
#[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
#[cfg_attr(feature = "full", ts(export))]
/// A post-view mode that changes how multiple post listings look.
pub enum PostViewMode {
pub enum PostListingMode {
/// A compact, list-type view.
List,
/// A larger card-type view.
Expand Down
162 changes: 81 additions & 81 deletions crates/db_schema/src/schema.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
// @generated automatically by Diesel CLI.

pub mod sql_types {
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "listing_type_enum"))]
pub struct ListingTypeEnum;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "listing_type_enum"))]
pub struct ListingTypeEnum;

#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "ltree"))]
pub struct Ltree;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "ltree"))]
pub struct Ltree;

#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "post_view_mode_enum"))]
pub struct PostViewModeEnum;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "post_listing_mode_enum"))]
pub struct PostListingModeEnum;

#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "registration_mode_enum"))]
pub struct RegistrationModeEnum;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "registration_mode_enum"))]
pub struct RegistrationModeEnum;

#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "sort_type_enum"))]
pub struct SortTypeEnum;
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "sort_type_enum"))]
pub struct SortTypeEnum;
}

diesel::table! {
Expand Down Expand Up @@ -380,7 +380,7 @@ diesel::table! {
use diesel::sql_types::*;
use super::sql_types::SortTypeEnum;
use super::sql_types::ListingTypeEnum;
use super::sql_types::PostViewModeEnum;
use super::sql_types::PostListingModeEnum;

local_user (id) {
id -> Int4,
Expand Down Expand Up @@ -408,7 +408,7 @@ diesel::table! {
blur_nsfw -> Bool,
auto_expand -> Bool,
infinite_scroll_enabled -> Bool,
post_view_mode -> PostViewModeEnum,
post_listing_mode -> PostListingModeEnum,
}
}

Expand Down Expand Up @@ -944,68 +944,68 @@ diesel::joinable!(site_language -> site (site_id));
diesel::joinable!(tagline -> local_site (local_site_id));

diesel::allow_tables_to_appear_in_same_query!(
admin_purge_comment,
admin_purge_community,
admin_purge_person,
admin_purge_post,
captcha_answer,
comment,
comment_aggregates,
comment_like,
comment_reply,
comment_report,
comment_saved,
community,
community_aggregates,
community_block,
community_follower,
community_language,
community_moderator,
community_person_ban,
custom_emoji,
custom_emoji_keyword,
email_verification,
federation_allowlist,
federation_blocklist,
instance,
language,
local_site,
local_site_rate_limit,
local_user,
local_user_language,
mod_add,
mod_add_community,
mod_ban,
mod_ban_from_community,
mod_feature_post,
mod_hide_community,
mod_lock_post,
mod_remove_comment,
mod_remove_community,
mod_remove_post,
mod_transfer_community,
password_reset_request,
person,
person_aggregates,
person_ban,
person_block,
person_follower,
person_mention,
person_post_aggregates,
post,
post_aggregates,
post_like,
post_read,
post_report,
post_saved,
private_message,
private_message_report,
received_activity,
registration_application,
secret,
sent_activity,
site,
site_aggregates,
site_language,
tagline,
admin_purge_comment,
admin_purge_community,
admin_purge_person,
admin_purge_post,
captcha_answer,
comment,
comment_aggregates,
comment_like,
comment_reply,
comment_report,
comment_saved,
community,
community_aggregates,
community_block,
community_follower,
community_language,
community_moderator,
community_person_ban,
custom_emoji,
custom_emoji_keyword,
email_verification,
federation_allowlist,
federation_blocklist,
instance,
language,
local_site,
local_site_rate_limit,
local_user,
local_user_language,
mod_add,
mod_add_community,
mod_ban,
mod_ban_from_community,
mod_feature_post,
mod_hide_community,
mod_lock_post,
mod_remove_comment,
mod_remove_community,
mod_remove_post,
mod_transfer_community,
password_reset_request,
person,
person_aggregates,
person_ban,
person_block,
person_follower,
person_mention,
person_post_aggregates,
post,
post_aggregates,
post_like,
post_read,
post_report,
post_saved,
private_message,
private_message_report,
received_activity,
registration_application,
secret,
sent_activity,
site,
site_aggregates,
site_language,
tagline,
);
8 changes: 4 additions & 4 deletions crates/db_schema/src/source/local_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::schema::local_user;
use crate::{
newtypes::{LocalUserId, PersonId},
ListingType,
PostViewMode,
PostListingMode,
SortType,
};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -58,7 +58,7 @@ pub struct LocalUser {
pub auto_expand: bool,
/// Whether infinite scroll is enabled.
pub infinite_scroll_enabled: bool,
pub post_view_mode: PostViewMode,
pub post_listing_mode: PostListingMode,
}

#[derive(Clone, TypedBuilder)]
Expand Down Expand Up @@ -90,7 +90,7 @@ pub struct LocalUserInsertForm {
pub blur_nsfw: Option<bool>,
pub auto_expand: Option<bool>,
pub infinite_scroll_enabled: Option<bool>,
pub post_view_mode: Option<PostViewMode>,
pub post_listing_mode: Option<PostListingMode>,
}

#[derive(Clone, Default)]
Expand Down Expand Up @@ -118,5 +118,5 @@ pub struct LocalUserUpdateForm {
pub blur_nsfw: Option<bool>,
pub auto_expand: Option<bool>,
pub infinite_scroll_enabled: Option<bool>,
pub post_view_mode: Option<PostViewMode>,
pub post_listing_mode: Option<PostListingMode>,
}
2 changes: 1 addition & 1 deletion crates/db_views/src/registration_application_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ mod tests {
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,
post_view_mode: inserted_sara_local_user.post_view_mode,
post_listing_mode: inserted_sara_local_user.post_listing_mode,
},
creator: Person {
id: inserted_sara_person.id,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE local_user
DROP COLUMN post_listing_mode;

DROP TYPE post_listing_mode_enum;

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TYPE post_listing_mode_enum AS enum (
'List',
'Card',
'SmallCard'
);

ALTER TABLE local_user
ADD COLUMN post_listing_mode post_listing_mode_enum DEFAULT 'List' NOT NULL;

0 comments on commit e351d49

Please sign in to comment.