mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-21 22:27:11 +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 {
|
||||
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;
|
||||
|
|
|
@ -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>
|
||||
)}
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
/>
|
||||
)}
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue