]> Untitled Git - lemmy.git/commitdiff
Add Creator flair for post creator / OPs comments
authorDessalines <tyhou13@gmx.com>
Fri, 13 Sep 2019 15:37:12 +0000 (08:37 -0700)
committerDessalines <tyhou13@gmx.com>
Fri, 13 Sep 2019 15:37:12 +0000 (08:37 -0700)
- Fixes #275

ui/src/components/comment-node.tsx
ui/src/components/comment-nodes.tsx
ui/src/components/post.tsx
ui/src/translations/en.ts

index a4e398f10740c28f974d91ff012cb4e3e3e48199..b45f13fcceca372be78b422044f5321624d92714 100644 (file)
@@ -33,6 +33,7 @@ interface CommentNodeProps {
   markable?: boolean;
   moderators: Array<CommunityUser>;
   admins: Array<UserView>;
+  postCreatorId?: number;
 }
 
 export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
@@ -87,6 +88,9 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
             {this.isAdmin && 
               <li className="list-inline-item badge badge-light"><T i18nKey="admin">#</T></li>
             }
+            {this.isPostCreator && 
+              <li className="list-inline-item badge badge-light"><T i18nKey="creator">#</T></li>
+            }
             {(node.comment.banned_from_community || node.comment.banned) &&  
               <li className="list-inline-item badge badge-danger"><T i18nKey="banned">#</T></li>
             }
@@ -255,6 +259,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
             locked={this.props.locked} 
             moderators={this.props.moderators}
             admins={this.props.admins}
+            postCreatorId={this.props.postCreatorId}
           />
         }
         {/* A collapsed clearfix */}
@@ -275,6 +280,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
     return this.props.admins && isMod(this.props.admins.map(a => a.id), this.props.node.comment.creator_id);
   }
 
+  get isPostCreator(): boolean {
+    return this.props.node.comment.creator_id == this.props.postCreatorId;
+  }
+
   get canMod(): boolean {
 
     if (this.props.admins && this.props.moderators) {
index fca323e395b78e6cc4e9a77fbe2158c6ef756864..1e61c2f04bfbc32f6d355cd8c1cedd6c2f33433e 100644 (file)
@@ -9,6 +9,7 @@ interface CommentNodesProps {
   nodes: Array<CommentNodeI>;
   moderators?: Array<CommunityUser>;
   admins?: Array<UserView>;
+  postCreatorId?: number;
   noIndent?: boolean;
   viewOnly?: boolean;
   locked?: boolean;
@@ -31,6 +32,7 @@ export class CommentNodes extends Component<CommentNodesProps, CommentNodesState
             locked={this.props.locked} 
             moderators={this.props.moderators}
             admins={this.props.admins}
+            postCreatorId={this.props.postCreatorId}
             markable={this.props.markable}
           />
         )}
index 5047d20b6cc0affe504693ef41d0eeee63ba08ef..07bddd343873c2c79ab017487fb630916efc9b7a 100644 (file)
@@ -183,6 +183,7 @@ export class Post extends Component<any, PostState> {
               locked={this.state.post.locked} 
               moderators={this.state.moderators} 
               admins={this.state.admins}
+              postCreatorId={this.state.post.creator_id}
             />
           )}
         </div>
@@ -256,6 +257,7 @@ export class Post extends Component<any, PostState> {
           locked={this.state.post.locked} 
           moderators={this.state.moderators} 
           admins={this.state.admins}
+          postCreatorId={this.state.post.creator_id}
         />
       </div>
     );
index 5ec036713909a6d473557e03ccbb15ff3c96a40e..459e3b79c8d332951663f636ad3304c44ce0c291 100644 (file)
@@ -64,6 +64,7 @@ export const en = {
     save: 'save',
     unsave: 'unsave',
     create: 'create',
+    creator: 'creator',
     username: 'Username',
     email_or_username: 'Email or Username',
     number_of_users:'{{count}} Users',