mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-15 00:43:59 +00:00
Merge branch 'main' into structs_separate
This commit is contained in:
commit
730cb6ce67
11 changed files with 72 additions and 13 deletions
|
@ -241,9 +241,11 @@ impl<'a> CommentQueryBuilder<'a> {
|
||||||
query = query.filter(content.ilike(fuzzy_search(&search_term)));
|
query = query.filter(content.ilike(fuzzy_search(&search_term)));
|
||||||
};
|
};
|
||||||
|
|
||||||
if let ListingType::Subscribed = self.listing_type {
|
query = match self.listing_type {
|
||||||
query = query.filter(subscribed.eq(true));
|
ListingType::Subscribed => query.filter(subscribed.eq(true)),
|
||||||
}
|
ListingType::Local => query.filter(community_local.eq(true)),
|
||||||
|
_ => query,
|
||||||
|
};
|
||||||
|
|
||||||
if self.saved_only {
|
if self.saved_only {
|
||||||
query = query.filter(saved.eq(true));
|
query = query.filter(saved.eq(true));
|
||||||
|
|
|
@ -147,6 +147,7 @@ pub enum SortType {
|
||||||
#[derive(EnumString, ToString, Debug, Serialize, Deserialize)]
|
#[derive(EnumString, ToString, Debug, Serialize, Deserialize)]
|
||||||
pub enum ListingType {
|
pub enum ListingType {
|
||||||
All,
|
All,
|
||||||
|
Local,
|
||||||
Subscribed,
|
Subscribed,
|
||||||
Community,
|
Community,
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,9 +267,11 @@ impl<'a> PostQueryBuilder<'a> {
|
||||||
|
|
||||||
let mut query = self.query;
|
let mut query = self.query;
|
||||||
|
|
||||||
if let ListingType::Subscribed = self.listing_type {
|
query = match self.listing_type {
|
||||||
query = query.filter(subscribed.eq(true));
|
ListingType::Subscribed => query.filter(subscribed.eq(true)),
|
||||||
}
|
ListingType::Local => query.filter(community_local.eq(true)),
|
||||||
|
_ => query,
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(for_community_id) = self.for_community_id {
|
if let Some(for_community_id) = self.for_community_id {
|
||||||
query = query.filter(community_id.eq(for_community_id));
|
query = query.filter(community_id.eq(for_community_id));
|
||||||
|
|
|
@ -125,6 +125,7 @@ impl<'a> UserQueryBuilder<'a> {
|
||||||
|
|
||||||
pub fn list(self) -> Result<Vec<UserView>, Error> {
|
pub fn list(self) -> Result<Vec<UserView>, Error> {
|
||||||
use super::user_view::user_fast::dsl::*;
|
use super::user_view::user_fast::dsl::*;
|
||||||
|
use diesel::sql_types::{Nullable, Text};
|
||||||
|
|
||||||
let mut query = self.query;
|
let mut query = self.query;
|
||||||
|
|
||||||
|
@ -154,6 +155,28 @@ impl<'a> UserQueryBuilder<'a> {
|
||||||
let (limit, offset) = limit_and_offset(self.page, self.limit);
|
let (limit, offset) = limit_and_offset(self.page, self.limit);
|
||||||
query = query.limit(limit).offset(offset);
|
query = query.limit(limit).offset(offset);
|
||||||
|
|
||||||
|
// The select is necessary here to not get back emails
|
||||||
|
query = query.select((
|
||||||
|
id,
|
||||||
|
actor_id,
|
||||||
|
name,
|
||||||
|
preferred_username,
|
||||||
|
avatar,
|
||||||
|
banner,
|
||||||
|
"".into_sql::<Nullable<Text>>(),
|
||||||
|
matrix_user_id,
|
||||||
|
bio,
|
||||||
|
local,
|
||||||
|
admin,
|
||||||
|
banned,
|
||||||
|
show_avatars,
|
||||||
|
send_notifications_to_email,
|
||||||
|
published,
|
||||||
|
number_of_posts,
|
||||||
|
post_score,
|
||||||
|
number_of_comments,
|
||||||
|
comment_score,
|
||||||
|
));
|
||||||
query.load::<UserView>(self.conn)
|
query.load::<UserView>(self.conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
ui/package.json
vendored
2
ui/package.json
vendored
|
@ -37,7 +37,7 @@
|
||||||
"inferno-router": "^7.4.2",
|
"inferno-router": "^7.4.2",
|
||||||
"js-cookie": "^2.2.0",
|
"js-cookie": "^2.2.0",
|
||||||
"jwt-decode": "^2.2.0",
|
"jwt-decode": "^2.2.0",
|
||||||
"lemmy-js-client": "^1.0.8",
|
"lemmy-js-client": "^1.0.9",
|
||||||
"markdown-it": "^11.0.0",
|
"markdown-it": "^11.0.0",
|
||||||
"markdown-it-container": "^3.0.0",
|
"markdown-it-container": "^3.0.0",
|
||||||
"markdown-it-emoji": "^1.4.0",
|
"markdown-it-emoji": "^1.4.0",
|
||||||
|
|
18
ui/src/components/listing-type-select.tsx
vendored
18
ui/src/components/listing-type-select.tsx
vendored
|
@ -6,6 +6,7 @@ import { i18n } from '../i18next';
|
||||||
|
|
||||||
interface ListingTypeSelectProps {
|
interface ListingTypeSelectProps {
|
||||||
type_: ListingType;
|
type_: ListingType;
|
||||||
|
showLocal?: boolean;
|
||||||
onChange?(val: ListingType): any;
|
onChange?(val: ListingType): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ export class ListingTypeSelect extends Component<
|
||||||
static getDerivedStateFromProps(props: any): ListingTypeSelectProps {
|
static getDerivedStateFromProps(props: any): ListingTypeSelectProps {
|
||||||
return {
|
return {
|
||||||
type_: props.type_,
|
type_: props.type_,
|
||||||
|
showLocal: props.showLocal,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +55,22 @@ export class ListingTypeSelect extends Component<
|
||||||
/>
|
/>
|
||||||
{i18n.t('subscribed')}
|
{i18n.t('subscribed')}
|
||||||
</label>
|
</label>
|
||||||
|
{this.props.showLocal && (
|
||||||
|
<label
|
||||||
|
className={`pointer btn btn-outline-secondary ${
|
||||||
|
this.state.type_ == ListingType.Local && 'active'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
id={`${this.id}-local`}
|
||||||
|
type="radio"
|
||||||
|
value={ListingType.Local}
|
||||||
|
checked={this.state.type_ == ListingType.Local}
|
||||||
|
onChange={linkEvent(this, this.handleTypeChange)}
|
||||||
|
/>
|
||||||
|
{i18n.t('local')}
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
<label
|
<label
|
||||||
className={`pointer btn btn-outline-secondary ${
|
className={`pointer btn btn-outline-secondary ${
|
||||||
this.state.type_ == ListingType.All && 'active'
|
this.state.type_ == ListingType.All && 'active'
|
||||||
|
|
4
ui/src/components/main.tsx
vendored
4
ui/src/components/main.tsx
vendored
|
@ -537,6 +537,10 @@ export class Main extends Component<any, MainState> {
|
||||||
<span class="mr-3">
|
<span class="mr-3">
|
||||||
<ListingTypeSelect
|
<ListingTypeSelect
|
||||||
type_={this.state.listingType}
|
type_={this.state.listingType}
|
||||||
|
showLocal={
|
||||||
|
this.state.siteRes.federated_instances &&
|
||||||
|
this.state.siteRes.federated_instances.length > 0
|
||||||
|
}
|
||||||
onChange={this.handleListingTypeChange}
|
onChange={this.handleListingTypeChange}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
|
3
ui/src/components/search.tsx
vendored
3
ui/src/components/search.tsx
vendored
|
@ -311,7 +311,6 @@ export class Search extends Component<any, SearchState> {
|
||||||
{i.type_ == 'users' && (
|
{i.type_ == 'users' && (
|
||||||
<div>
|
<div>
|
||||||
<span>
|
<span>
|
||||||
@
|
|
||||||
<UserListing
|
<UserListing
|
||||||
user={{
|
user={{
|
||||||
name: (i.data as UserView).name,
|
name: (i.data as UserView).name,
|
||||||
|
@ -398,11 +397,11 @@ export class Search extends Component<any, SearchState> {
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<span>
|
<span>
|
||||||
@
|
|
||||||
<UserListing
|
<UserListing
|
||||||
user={{
|
user={{
|
||||||
name: user.name,
|
name: user.name,
|
||||||
avatar: user.avatar,
|
avatar: user.avatar,
|
||||||
|
preferred_username: user.preferred_username,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
|
4
ui/src/components/user.tsx
vendored
4
ui/src/components/user.tsx
vendored
|
@ -539,6 +539,10 @@ export class User extends Component<any, UserState> {
|
||||||
this.state.userSettingsForm.default_listing_type
|
this.state.userSettingsForm.default_listing_type
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
showLocal={
|
||||||
|
this.state.siteRes.federated_instances &&
|
||||||
|
this.state.siteRes.federated_instances.length > 0
|
||||||
|
}
|
||||||
onChange={this.handleUserSettingsListingTypeChange}
|
onChange={this.handleUserSettingsListingTypeChange}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
|
1
ui/translations/en.json
vendored
1
ui/translations/en.json
vendored
|
@ -139,6 +139,7 @@
|
||||||
"month": "Month",
|
"month": "Month",
|
||||||
"year": "Year",
|
"year": "Year",
|
||||||
"all": "All",
|
"all": "All",
|
||||||
|
"local": "Local",
|
||||||
"top": "Top",
|
"top": "Top",
|
||||||
"api": "API",
|
"api": "API",
|
||||||
"docs": "Docs",
|
"docs": "Docs",
|
||||||
|
|
13
ui/yarn.lock
vendored
13
ui/yarn.lock
vendored
|
@ -4938,10 +4938,10 @@ lego-api@^1.0.7:
|
||||||
dependencies:
|
dependencies:
|
||||||
chain-able "^3.0.0"
|
chain-able "^3.0.0"
|
||||||
|
|
||||||
lemmy-js-client@^1.0.8:
|
lemmy-js-client@^1.0.9:
|
||||||
version "1.0.8"
|
version "1.0.9"
|
||||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.8.tgz#98e34c8e3cd07427f883f60fad376dc4d6f46e7f"
|
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.9.tgz#23cab713613612a524085d6bb3fc1d4042d262a8"
|
||||||
integrity sha512-YZxD3+8RGz7cRKdI8EIe5iQqQIMm5WzdNz6zZ7/CdkMtXUv6YuMOEv8HLTvBoGuaWIJwlMJ+23NIarxlT26IEw==
|
integrity sha512-QJc4d1HkSxjv555yH3MAOYbTfgbhmmvvuC1uhFvPwBlL5B5MTry/fWPRbtLfkYTxdZWftE+PYvLVKPr3/dFmxw==
|
||||||
|
|
||||||
leven@^3.1.0:
|
leven@^3.1.0:
|
||||||
version "3.1.0"
|
version "3.1.0"
|
||||||
|
@ -7017,6 +7017,11 @@ regexpu-core@^4.1.3:
|
||||||
unicode-match-property-ecmascript "^1.0.4"
|
unicode-match-property-ecmascript "^1.0.4"
|
||||||
unicode-match-property-value-ecmascript "^1.2.0"
|
unicode-match-property-value-ecmascript "^1.2.0"
|
||||||
|
|
||||||
|
register-service-worker@^1.7.1:
|
||||||
|
version "1.7.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/register-service-worker/-/register-service-worker-1.7.1.tgz#6308347ac6c0af0f6c0b22ea5d59d25e836bc932"
|
||||||
|
integrity sha512-IdTfUZ4u8iJL8o1w8es8l6UMGPmkwHolUdT+UmM1UypC80IB4KbpuIlvwWVj8UDS7eJwkEYRcKRgfRX+oTmJsw==
|
||||||
|
|
||||||
registry-auth-token@^3.0.1:
|
registry-auth-token@^3.0.1:
|
||||||
version "3.4.0"
|
version "3.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.4.0.tgz#d7446815433f5d5ed6431cd5dca21048f66b397e"
|
resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.4.0.tgz#d7446815433f5d5ed6431cd5dca21048f66b397e"
|
||||||
|
|
Loading…
Reference in a new issue