Making communities in PostForm optional. Fixing private-message.

This commit is contained in:
Dessalines 2020-09-08 22:31:18 -05:00
parent b7f1b9c2d7
commit 06955a0e37
7 changed files with 15 additions and 30 deletions

View file

@ -46,7 +46,7 @@ const MAX_POST_TITLE_LENGTH = 200;
interface PostFormProps {
post?: Post; // If a post is given, that means this is an edit
communities: Community[];
communities?: Community[];
params?: PostFormParams;
onCancel?(): any;
onCreate?(id: number): any;

View file

@ -17,7 +17,6 @@ import {
AddAdminForm,
TransferSiteForm,
TransferCommunityForm,
Community,
} from 'lemmy-js-client';
import { BanType } from '../interfaces';
import { MomentTime } from './moment-time';
@ -62,7 +61,6 @@ interface PostListingState {
interface PostListingProps {
post: Post;
communities: Community[]; // TODO this should be an optional
showCommunity?: boolean;
showBody?: boolean;
moderators?: CommunityUser[];
@ -129,7 +127,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
onCancel={this.handleEditCancel}
enableNsfw={this.props.enableNsfw}
enableDownvotes={this.props.enableDownvotes}
communities={this.props.communities}
/>
</div>
)}

View file

@ -27,7 +27,6 @@ export class PostListings extends Component<PostListingsProps, any> {
this.outer().map(post => (
<>
<PostListing
communities={[]}
post={post}
showCommunity={this.props.showCommunity}
enableDownvotes={this.props.enableDownvotes}

View file

@ -225,7 +225,6 @@ export class Post extends Component<any, PostState> {
<div class="row">
<div class="col-12 col-md-8 mb-3">
<PostListing
communities={[this.state.postRes.community]}
post={this.state.postRes.post}
showBody
showCommunity

View file

@ -9,7 +9,7 @@ import { WebSocketService, UserService } from '../services';
import { mdToHtml, toast } from '../utils';
import { MomentTime } from './moment-time';
import { PrivateMessageForm } from './private-message-form';
import { UserListing, UserOther } from './user-listing';
import { UserListing } from './user-listing';
import { i18n } from '../i18next';
interface PrivateMessageState {
@ -17,7 +17,6 @@ interface PrivateMessageState {
showEdit: boolean;
collapsed: boolean;
viewSource: boolean;
recipient: UserView;
}
interface PrivateMessageProps {
@ -33,21 +32,6 @@ export class PrivateMessage extends Component<
showEdit: false,
collapsed: 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) {
@ -70,7 +54,7 @@ export class PrivateMessage extends Component<
render() {
let message = this.props.privateMessage;
let userOther: UserOther = this.mine
let userOther: UserView = this.mine
? {
name: message.recipient_name,
preferred_username: message.recipient_preferred_username,
@ -79,6 +63,11 @@ export class PrivateMessage extends Component<
local: message.recipient_local,
actor_id: message.recipient_actor_id,
published: message.published,
number_of_posts: 0,
post_score: 0,
number_of_comments: 0,
comment_score: 0,
banned: false,
}
: {
name: message.creator_name,
@ -88,6 +77,11 @@ export class PrivateMessage extends Component<
local: message.creator_local,
actor_id: message.creator_actor_id,
published: message.published,
number_of_posts: 0,
post_score: 0,
number_of_comments: 0,
comment_score: 0,
banned: false,
};
return (
@ -125,7 +119,7 @@ export class PrivateMessage extends Component<
</ul>
{this.state.showEdit && (
<PrivateMessageForm
recipient={this.state.recipient}
recipient={userOther}
privateMessage={message}
onEdit={this.handlePrivateMessageEdit}
onCreate={this.handlePrivateMessageCreate}
@ -232,7 +226,7 @@ export class PrivateMessage extends Component<
</div>
{this.state.showReply && (
<PrivateMessageForm
recipient={this.state.recipient}
recipient={userOther}
onCreate={this.handlePrivateMessageCreate}
/>
)}

View file

@ -297,7 +297,6 @@ export class Search extends Component<any, SearchState> {
<div class="col-12">
{i.type_ == 'posts' && (
<PostListing
communities={[]}
key={(i.data as Post).id}
post={i.data as Post}
showCommunity
@ -360,7 +359,6 @@ export class Search extends Component<any, SearchState> {
<div class="row">
<div class="col-12">
<PostListing
communities={[]}
post={post}
showCommunity
enableDownvotes={this.state.site.enable_downvotes}

View file

@ -87,7 +87,6 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
<div>
{i.type === 'posts' ? (
<PostListing
communities={[]}
key={(i.data as Post).id}
post={i.data as Post}
admins={this.props.userRes.admins}
@ -136,7 +135,6 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
{this.props.userRes.posts.map(post => (
<>
<PostListing
communities={[]}
post={post}
admins={this.props.userRes.admins}
showCommunity