]> Untitled Git - lemmy-ui.git/commitdiff
Making communities in PostForm optional. Fixing private-message.
authorDessalines <tyhou13@gmx.com>
Wed, 9 Sep 2020 03:31:18 +0000 (22:31 -0500)
committerDessalines <tyhou13@gmx.com>
Wed, 9 Sep 2020 03:31:18 +0000 (22:31 -0500)
src/shared/components/post-form.tsx
src/shared/components/post-listing.tsx
src/shared/components/post-listings.tsx
src/shared/components/post.tsx
src/shared/components/private-message.tsx
src/shared/components/search.tsx
src/shared/components/user-details.tsx

index f37b5bc0d967e82dddf9203cdd78fa19c759e051..dd5d5495a66092050820dff05f5947997fd91769 100644 (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;
index ade3740fbc89b315c35fec94caa2c72873668fd3..23eed736c7b6b88926d8dd0454bf17fd011fd265 100644 (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>
         )}
index 4f1f586f2e5ec02c5692b58e57e14ec206a8492e..47aab75460ec4fe1995d50add17910face13bbe4 100644 (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}
index 1406de70ac0aec008a5f7d889fbe78d93641e478..e3ff2649c6979f9a4ce618eff0c8e5e09e053087 100644 (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
index 18154f8e1f7dc192e68c787e8ca307a1e214476b..30f74156e74ee7d6d110c6ba95a62772951c5d9a 100644 (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}
           />
         )}
index e086a92184ee647016b9fab8674cd169d14d35c8..b032d456c9137b762e2ccea2a1582bd4ad9790b1 100644 (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}
index 834000e2b4b367d27b88de6600d6e1ad83ca754c..01c9aed1c72eab95a585cb3709ae672e64649b78 100644 (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