mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-25 07:36:37 +00:00
Making communities in PostForm optional. Fixing private-message.
This commit is contained in:
parent
b7f1b9c2d7
commit
06955a0e37
|
@ -46,7 +46,7 @@ const MAX_POST_TITLE_LENGTH = 200;
|
||||||
|
|
||||||
interface PostFormProps {
|
interface PostFormProps {
|
||||||
post?: Post; // If a post is given, that means this is an edit
|
post?: Post; // If a post is given, that means this is an edit
|
||||||
communities: Community[];
|
communities?: Community[];
|
||||||
params?: PostFormParams;
|
params?: PostFormParams;
|
||||||
onCancel?(): any;
|
onCancel?(): any;
|
||||||
onCreate?(id: number): any;
|
onCreate?(id: number): any;
|
||||||
|
|
|
@ -17,7 +17,6 @@ import {
|
||||||
AddAdminForm,
|
AddAdminForm,
|
||||||
TransferSiteForm,
|
TransferSiteForm,
|
||||||
TransferCommunityForm,
|
TransferCommunityForm,
|
||||||
Community,
|
|
||||||
} from 'lemmy-js-client';
|
} from 'lemmy-js-client';
|
||||||
import { BanType } from '../interfaces';
|
import { BanType } from '../interfaces';
|
||||||
import { MomentTime } from './moment-time';
|
import { MomentTime } from './moment-time';
|
||||||
|
@ -62,7 +61,6 @@ interface PostListingState {
|
||||||
|
|
||||||
interface PostListingProps {
|
interface PostListingProps {
|
||||||
post: Post;
|
post: Post;
|
||||||
communities: Community[]; // TODO this should be an optional
|
|
||||||
showCommunity?: boolean;
|
showCommunity?: boolean;
|
||||||
showBody?: boolean;
|
showBody?: boolean;
|
||||||
moderators?: CommunityUser[];
|
moderators?: CommunityUser[];
|
||||||
|
@ -129,7 +127,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
onCancel={this.handleEditCancel}
|
onCancel={this.handleEditCancel}
|
||||||
enableNsfw={this.props.enableNsfw}
|
enableNsfw={this.props.enableNsfw}
|
||||||
enableDownvotes={this.props.enableDownvotes}
|
enableDownvotes={this.props.enableDownvotes}
|
||||||
communities={this.props.communities}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -27,7 +27,6 @@ export class PostListings extends Component<PostListingsProps, any> {
|
||||||
this.outer().map(post => (
|
this.outer().map(post => (
|
||||||
<>
|
<>
|
||||||
<PostListing
|
<PostListing
|
||||||
communities={[]}
|
|
||||||
post={post}
|
post={post}
|
||||||
showCommunity={this.props.showCommunity}
|
showCommunity={this.props.showCommunity}
|
||||||
enableDownvotes={this.props.enableDownvotes}
|
enableDownvotes={this.props.enableDownvotes}
|
||||||
|
|
|
@ -225,7 +225,6 @@ export class Post extends Component<any, PostState> {
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-md-8 mb-3">
|
<div class="col-12 col-md-8 mb-3">
|
||||||
<PostListing
|
<PostListing
|
||||||
communities={[this.state.postRes.community]}
|
|
||||||
post={this.state.postRes.post}
|
post={this.state.postRes.post}
|
||||||
showBody
|
showBody
|
||||||
showCommunity
|
showCommunity
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { WebSocketService, UserService } from '../services';
|
||||||
import { mdToHtml, toast } from '../utils';
|
import { mdToHtml, toast } from '../utils';
|
||||||
import { MomentTime } from './moment-time';
|
import { MomentTime } from './moment-time';
|
||||||
import { PrivateMessageForm } from './private-message-form';
|
import { PrivateMessageForm } from './private-message-form';
|
||||||
import { UserListing, UserOther } from './user-listing';
|
import { UserListing } from './user-listing';
|
||||||
import { i18n } from '../i18next';
|
import { i18n } from '../i18next';
|
||||||
|
|
||||||
interface PrivateMessageState {
|
interface PrivateMessageState {
|
||||||
|
@ -17,7 +17,6 @@ interface PrivateMessageState {
|
||||||
showEdit: boolean;
|
showEdit: boolean;
|
||||||
collapsed: boolean;
|
collapsed: boolean;
|
||||||
viewSource: boolean;
|
viewSource: boolean;
|
||||||
recipient: UserView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PrivateMessageProps {
|
interface PrivateMessageProps {
|
||||||
|
@ -33,21 +32,6 @@ export class PrivateMessage extends Component<
|
||||||
showEdit: false,
|
showEdit: false,
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
viewSource: false,
|
viewSource: false,
|
||||||
recipient: {
|
|
||||||
id: this.props.privateMessage.recipient_id,
|
|
||||||
actor_id: this.props.privateMessage.recipient_actor_id,
|
|
||||||
name: this.props.privateMessage.recipient_name,
|
|
||||||
local: this.props.privateMessage.recipient_local,
|
|
||||||
avatar: this.props.privateMessage.recipient_avatar,
|
|
||||||
preferred_username: this.props.privateMessage
|
|
||||||
.recipient_preferred_username,
|
|
||||||
published: undefined,
|
|
||||||
number_of_posts: 0,
|
|
||||||
post_score: 0,
|
|
||||||
number_of_comments: 0,
|
|
||||||
comment_score: 0,
|
|
||||||
banned: false,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props: any, context: any) {
|
constructor(props: any, context: any) {
|
||||||
|
@ -70,7 +54,7 @@ export class PrivateMessage extends Component<
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let message = this.props.privateMessage;
|
let message = this.props.privateMessage;
|
||||||
let userOther: UserOther = this.mine
|
let userOther: UserView = this.mine
|
||||||
? {
|
? {
|
||||||
name: message.recipient_name,
|
name: message.recipient_name,
|
||||||
preferred_username: message.recipient_preferred_username,
|
preferred_username: message.recipient_preferred_username,
|
||||||
|
@ -79,6 +63,11 @@ export class PrivateMessage extends Component<
|
||||||
local: message.recipient_local,
|
local: message.recipient_local,
|
||||||
actor_id: message.recipient_actor_id,
|
actor_id: message.recipient_actor_id,
|
||||||
published: message.published,
|
published: message.published,
|
||||||
|
number_of_posts: 0,
|
||||||
|
post_score: 0,
|
||||||
|
number_of_comments: 0,
|
||||||
|
comment_score: 0,
|
||||||
|
banned: false,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
name: message.creator_name,
|
name: message.creator_name,
|
||||||
|
@ -88,6 +77,11 @@ export class PrivateMessage extends Component<
|
||||||
local: message.creator_local,
|
local: message.creator_local,
|
||||||
actor_id: message.creator_actor_id,
|
actor_id: message.creator_actor_id,
|
||||||
published: message.published,
|
published: message.published,
|
||||||
|
number_of_posts: 0,
|
||||||
|
post_score: 0,
|
||||||
|
number_of_comments: 0,
|
||||||
|
comment_score: 0,
|
||||||
|
banned: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -125,7 +119,7 @@ export class PrivateMessage extends Component<
|
||||||
</ul>
|
</ul>
|
||||||
{this.state.showEdit && (
|
{this.state.showEdit && (
|
||||||
<PrivateMessageForm
|
<PrivateMessageForm
|
||||||
recipient={this.state.recipient}
|
recipient={userOther}
|
||||||
privateMessage={message}
|
privateMessage={message}
|
||||||
onEdit={this.handlePrivateMessageEdit}
|
onEdit={this.handlePrivateMessageEdit}
|
||||||
onCreate={this.handlePrivateMessageCreate}
|
onCreate={this.handlePrivateMessageCreate}
|
||||||
|
@ -232,7 +226,7 @@ export class PrivateMessage extends Component<
|
||||||
</div>
|
</div>
|
||||||
{this.state.showReply && (
|
{this.state.showReply && (
|
||||||
<PrivateMessageForm
|
<PrivateMessageForm
|
||||||
recipient={this.state.recipient}
|
recipient={userOther}
|
||||||
onCreate={this.handlePrivateMessageCreate}
|
onCreate={this.handlePrivateMessageCreate}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -297,7 +297,6 @@ export class Search extends Component<any, SearchState> {
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
{i.type_ == 'posts' && (
|
{i.type_ == 'posts' && (
|
||||||
<PostListing
|
<PostListing
|
||||||
communities={[]}
|
|
||||||
key={(i.data as Post).id}
|
key={(i.data as Post).id}
|
||||||
post={i.data as Post}
|
post={i.data as Post}
|
||||||
showCommunity
|
showCommunity
|
||||||
|
@ -360,7 +359,6 @@ export class Search extends Component<any, SearchState> {
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<PostListing
|
<PostListing
|
||||||
communities={[]}
|
|
||||||
post={post}
|
post={post}
|
||||||
showCommunity
|
showCommunity
|
||||||
enableDownvotes={this.state.site.enable_downvotes}
|
enableDownvotes={this.state.site.enable_downvotes}
|
||||||
|
|
|
@ -87,7 +87,6 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
||||||
<div>
|
<div>
|
||||||
{i.type === 'posts' ? (
|
{i.type === 'posts' ? (
|
||||||
<PostListing
|
<PostListing
|
||||||
communities={[]}
|
|
||||||
key={(i.data as Post).id}
|
key={(i.data as Post).id}
|
||||||
post={i.data as Post}
|
post={i.data as Post}
|
||||||
admins={this.props.userRes.admins}
|
admins={this.props.userRes.admins}
|
||||||
|
@ -136,7 +135,6 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
||||||
{this.props.userRes.posts.map(post => (
|
{this.props.userRes.posts.map(post => (
|
||||||
<>
|
<>
|
||||||
<PostListing
|
<PostListing
|
||||||
communities={[]}
|
|
||||||
post={post}
|
post={post}
|
||||||
admins={this.props.userRes.admins}
|
admins={this.props.userRes.admins}
|
||||||
showCommunity
|
showCommunity
|
||||||
|
|
Loading…
Reference in a new issue