summaryrefslogtreecommitdiffstats
path: root/ui/src/components/comment-node.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/components/comment-node.tsx')
-rw-r--r--ui/src/components/comment-node.tsx588
1 files changed, 433 insertions, 155 deletions
diff --git a/ui/src/components/comment-node.tsx b/ui/src/components/comment-node.tsx
index ce4bb510..7eb5d9d4 100644
--- a/ui/src/components/comment-node.tsx
+++ b/ui/src/components/comment-node.tsx
@@ -1,6 +1,20 @@
import { Component, linkEvent } from 'inferno';
import { Link } from 'inferno-router';
-import { CommentNode as CommentNodeI, CommentLikeForm, CommentForm as CommentFormI, SaveCommentForm, BanFromCommunityForm, BanUserForm, CommunityUser, UserView, AddModToCommunityForm, AddAdminForm, TransferCommunityForm, TransferSiteForm, BanType } from '../interfaces';
+import {
+ CommentNode as CommentNodeI,
+ CommentLikeForm,
+ CommentForm as CommentFormI,
+ SaveCommentForm,
+ BanFromCommunityForm,
+ BanUserForm,
+ CommunityUser,
+ UserView,
+ AddModToCommunityForm,
+ AddAdminForm,
+ TransferCommunityForm,
+ TransferSiteForm,
+ BanType,
+} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import { mdToHtml, getUnixTime, canMod, isMod } from '../utils';
import * as moment from 'moment';
@@ -37,7 +51,6 @@ interface CommentNodeProps {
}
export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
-
private emptyState: CommentNodeState = {
showReply: false,
showEdit: false,
@@ -51,7 +64,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
viewSource: false,
showConfirmTransferSite: false,
showConfirmTransferCommunity: false,
- }
+ };
constructor(props: any, context: any) {
super(props, context);
@@ -65,176 +78,405 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
render() {
let node = this.props.node;
return (
- <div className={`comment ${node.comment.parent_id && !this.props.noIndent ? 'ml-4' : ''}`}>
- {!this.state.collapsed &&
- <div className={`vote-bar mr-2 float-left small text-center ${this.props.viewOnly && 'no-click'}`}>
- <button className={`btn p-0 ${node.comment.my_vote == 1 ? 'text-info' : 'text-muted'}`} onClick={linkEvent(node, this.handleCommentLike)}>
- <svg class="icon upvote"><use xlinkHref="#icon-arrow-up"></use></svg>
+ <div
+ className={`comment ${
+ node.comment.parent_id && !this.props.noIndent ? 'ml-4' : ''
+ }`}
+ >
+ {!this.state.collapsed && (
+ <div
+ className={`vote-bar mr-2 float-left small text-center ${this.props
+ .viewOnly && 'no-click'}`}
+ >
+ <button
+ className={`btn p-0 ${
+ node.comment.my_vote == 1 ? 'text-info' : 'text-muted'
+ }`}
+ onClick={linkEvent(node, this.handleCommentLike)}
+ >
+ <svg class="icon upvote">
+ <use xlinkHref="#icon-arrow-up"></use>
+ </svg>
</button>
- <div class={`font-weight-bold text-muted`}>{node.comment.score}</div>
- <button className={`btn p-0 ${node.comment.my_vote == -1 ? 'text-danger' : 'text-muted'}`} onClick={linkEvent(node, this.handleCommentDisLike)}>
- <svg class="icon downvote"><use xlinkHref="#icon-arrow-down"></use></svg>
+ <div class={`font-weight-bold text-muted`}>
+ {node.comment.score}
+ </div>
+ <button
+ className={`btn p-0 ${
+ node.comment.my_vote == -1 ? 'text-danger' : 'text-muted'
+ }`}
+ onClick={linkEvent(node, this.handleCommentDisLike)}
+ >
+ <svg class="icon downvote">
+ <use xlinkHref="#icon-arrow-down"></use>
+ </svg>
</button>
</div>
- }
- <div id={`comment-${node.comment.id}`} className={`details comment-node ml-4 ${this.isCommentNew ? 'mark' : ''}`}>
+ )}
+ <div
+ id={`comment-${node.comment.id}`}
+ className={`details comment-node ml-4 ${
+ this.isCommentNew ? 'mark' : ''
+ }`}
+ >
<ul class="list-inline mb-0 text-muted small">
<li className="list-inline-item">
- <Link className="text-info" to={`/u/${node.comment.creator_name}`}>{node.comment.creator_name}</Link>
+ <Link
+ className="text-info"
+ to={`/u/${node.comment.creator_name}`}
+ >
+ {node.comment.creator_name}
+ </Link>
</li>
- {this.isMod &&
- <li className="list-inline-item badge badge-light"><T i18nKey="mod">#</T></li>
- }
- {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>
- }
+ {this.isMod && (
+ <li className="list-inline-item badge badge-light">
+ <T i18nKey="mod">#</T>
+ </li>
+ )}
+ {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>
+ )}
<li className="list-inline-item">
- <span>(
- <span className="text-info">+{node.comment.upvotes}</span>
+ <span>
+ (<span className="text-info">+{node.comment.upvotes}</span>
<span> | </span>
<span className="text-danger">-{node.comment.downvotes}</span>
<span>) </span>
</span>
</li>
<li className="list-inline-item">
- <span><MomentTime data={node.comment} /></span>
+ <span>
+ <MomentTime data={node.comment} />
+ </span>
</li>
<li className="list-inline-item">
- <div className="pointer text-monospace" onClick={linkEvent(this, this.handleCommentCollapse)}>{this.state.collapsed ? '[+]' : '[-]'}</div>
+ <div
+ className="pointer text-monospace"
+ onClick={linkEvent(this, this.handleCommentCollapse)}
+ >
+ {this.state.collapsed ? '[+]' : '[-]'}
+ </div>
</li>
</ul>
- {this.state.showEdit && <CommentForm node={node} edit onReplyCancel={this.handleReplyCancel} disabled={this.props.locked} />}
- {!this.state.showEdit && !this.state.collapsed &&
+ {this.state.showEdit && (
+ <CommentForm
+ node={node}
+ edit
+ onReplyCancel={this.handleReplyCancel}
+ disabled={this.props.locked}
+ />
+ )}
+ {!this.state.showEdit && !this.state.collapsed && (
<div>
- {this.state.viewSource ? <pre>{this.commentUnlessRemoved}</pre> :
- <div className="md-div" dangerouslySetInnerHTML={mdToHtml(this.commentUnlessRemoved)} />
- }
+ {this.state.viewSource ? (
+ <pre>{this.commentUnlessRemoved}</pre>
+ ) : (
+ <div
+ className="md-div"
+ dangerouslySetInnerHTML={mdToHtml(this.commentUnlessRemoved)}
+ />
+ )}
<ul class="list-inline mb-1 text-muted small font-weight-bold">
- {UserService.Instance.user && !this.props.viewOnly &&
+ {UserService.Instance.user && !this.props.viewOnly && (
<>
<li className="list-inline-item">
- <span class="pointer" onClick={linkEvent(this, this.handleReplyClick)}><T i18nKey="reply">#</T></span>
+ <span
+ class="pointer"
+ onClick={linkEvent(this, this.handleReplyClick)}
+ >
+ <T i18nKey="reply">#</T>
+ </span>
</li>
<li className="list-inline-item mr-2">
- <span class="pointer" onClick={linkEvent(this, this.handleSaveCommentClick)}>{node.comment.saved ? i18n.t('unsave') : i18n.t('save')}</span>
+ <span
+ class="pointer"
+ onClick={linkEvent(this, this.handleSaveCommentClick)}
+ >
+ {node.comment.saved ? i18n.t('unsave') : i18n.t('save')}
+ </span>
</li>
- {this.myComment &&
+ {this.myComment && (
<>
<li className="list-inline-item">
- <span class="pointer" onClick={linkEvent(this, this.handleEditClick)}><T i18nKey="edit">#</T></span>
+ <span
+ class="pointer"
+ onClick={linkEvent(this, this.handleEditClick)}
+ >
+ <T i18nKey="edit">#</T>
+ </span>
</li>
<li className="list-inline-item">
- <span class="pointer" onClick={linkEvent(this, this.handleDeleteClick)}>
- {!node.comment.deleted ? i18n.t('delete') : i18n.t('restore')}
+ <span
+ class="pointer"
+ onClick={linkEvent(this, this.handleDeleteClick)}
+ >
+ {!node.comment.deleted
+ ? i18n.t('delete')
+ : i18n.t('restore')}
</span>
</li>
</>
- }
+ )}
{/* Admins and mods can remove comments */}
- {(this.canMod || this.canAdmin) &&
+ {(this.canMod || this.canAdmin) && (
<li className="list-inline-item">
- {!node.comment.removed ?
- <span class="pointer" onClick={linkEvent(this, this.handleModRemoveShow)}><T i18nKey="remove">#</T></span> :
- <span class="pointer" onClick={linkEvent(this, this.handleModRemoveSubmit)}><T i18nKey="restore">#</T></span>
- }
+ {!node.comment.removed ? (
+ <span
+ class="pointer"
+ onClick={linkEvent(this, this.handleModRemoveShow)}
+ >
+ <T i18nKey="remove">#</T>
+ </span>
+ ) : (
+ <span
+ class="pointer"
+ onClick={linkEvent(
+ this,
+ this.handleModRemoveSubmit
+ )}
+ >
+ <T i18nKey="restore">#</T>
+ </span>
+ )}
</li>
- }
+ )}
{/* Mods can ban from community, and appoint as mods to community */}
- {this.canMod &&
+ {this.canMod && (
<>
- {!this.isMod &&
+ {!this.isMod && (
<li className="list-inline-item">
- {!node.comment.banned_from_community ?
- <span class="pointer" onClick={linkEvent(this, this.handleModBanFromCommunityShow)}><T i18nKey="ban">#</T></span> :
- <span class="pointer" onClick={linkEvent(this, this.handleModBanFromCommunitySubmit)}><T i18nKey="unban">#</T></span>
- }
+ {!node.comment.banned_from_community ? (
+ <span
+ class="pointer"
+ onClick={linkEvent(
+ this,
+ this.handleModBanFromCommunityShow
+ )}
+ >
+ <T i18nKey="ban">#</T>
+ </span>
+ ) : (
+ <span
+ class="pointer"
+ onClick={linkEvent(
+ this,
+ this.handleModBanFromCommunitySubmit
+ )}
+ >
+ <T i18nKey="unban">#</T>
+ </span>
+ )}
</li>
- }
- {!node.comment.banned_from_community &&
+ )}
+ {!node.comment.banned_from_community && (
<li className="list-inline-item">
- <span class="pointer" onClick={linkEvent(this, this.handleAddModToCommunity)}>{this.isMod ? i18n.t('remove_as_mod') : i18n.t('appoint_as_mod')}</span>
+ <span
+ class="pointer"
+ onClick={linkEvent(
+ this,
+ this.handleAddModToCommunity
+ )}
+ >
+ {this.isMod
+ ? i18n.t('remove_as_mod')
+ : i18n.t('appoint_as_mod')}
+ </span>
</li>
- }
+ )}
</>
- }
+ )}
{/* Community creators and admins can transfer community to another mod */}
- {(this.amCommunityCreator || this.canAdmin) && this.isMod &&
+ {(this.amCommunityCreator || this.canAdmin) && this.isMod && (
<li className="list-inline-item">
- {!this.state.showConfirmTransferCommunity ?
- <span class="pointer" onClick={linkEvent(this, this.handleShowConfirmTransferCommunity)}><T i18nKey="transfer_community">#</T>
- </span> : <>
- <span class="d-inline-block mr-1"><T i18nKey="are_you_sure">#</T></span>
- <span class="pointer d-inline-block mr-1" onClick={linkEvent(this, this.handleTransferCommunity)}><T i18nKey="yes">#</T></span>
- <span class="pointer d-inline-block" onClick={linkEvent(this, this.handleCancelShowConfirmTransferCommunity)}><T i18nKey="no">#</T></span>
- </>
- }
+ {!this.state.showConfirmTransferCommunity ? (
+ <span
+ class="pointer"
+ onClick={linkEvent(
+ this,
+ this.handleShowConfirmTransferCommunity
+ )}
+ >
+ <T i18nKey="transfer_community">#</T>
+ </span>
+ ) : (
+ <>
+ <span class="d-inline-block mr-1">
+ <T i18nKey="are_you_sure">#</T>
+ </span>
+ <span
+ class="pointer d-inline-block mr-1"
+ onClick={linkEvent(
+ this,
+ this.handleTransferCommunity
+ )}
+ >
+ <T i18nKey="yes">#</T>
+ </span>
+ <span
+ class="pointer d-inline-block"
+ onClick={linkEvent(
+ this,
+ this.handleCancelShowConfirmTransferCommunity
+ )}
+ >
+ <T i18nKey="no">#</T>
+ </span>
+ </>
+ )}
</li>
- }
+ )}
{/* Admins can ban from all, and appoint other admins */}
- {this.canAdmin &&
+ {this.canAdmin && (
<>
- {!this.isAdmin &&
+ {!this.isAdmin && (
<li className="list-inline-item">
- {!node.comment.banned ?
- <span class="pointer" onClick={linkEvent(this, this.handleModBanShow)}><T i18nKey="ban_from_site">#</T></span> :
- <span class="pointer" onClick={linkEvent(this, this.handleModBanSubmit)}><T i18nKey="unban_from_site">#</T></span>
- }
+ {!node.comment.banned ? (
+ <span
+ class="pointer"
+ onClick={linkEvent(this, this.handleModBanShow)}
+ >
+ <T i18nKey="ban_from_site">#</T>
+ </span>
+ ) : (
+ <span
+ class="pointer"
+ onClick={linkEvent(
+ this,
+ this.handleModBanSubmit
+ )}
+ >
+ <T i18nKey="unban_from_site">#</T>
+ </span>
+ )}
</li>
- }
- {!node.comment.banned &&
+ )}
+ {!node.comment.banned && (
<li className="list-inline-item">
- <span class="pointer" onClick={linkEvent(this, this.handleAddAdmin)}>{this.isAdmin ? i18n.t('remove_as_admin') : i18n.t('appoint_as_admin')}</span>
+ <span
+ class="pointer"
+ onClick={linkEvent(this, this.handleAddAdmin)}
+ >
+ {this.isAdmin
+ ? i18n.t('remove_as_admin')
+ : i18n.t('appoint_as_admin')}
+ </span>
</li>
- }
+ )}
</>
- }
+ )}
{/* Site Creator can transfer to another admin */}
- {this.amSiteCreator && this.isAdmin &&
+ {this.amSiteCreator && this.isAdmin && (
<li className="list-inline-item">
- {!this.state.showConfirmTransferSite ?
- <span class="pointer" onClick={linkEvent(this, this.handleShowConfirmTransferSite)}><T i18nKey="transfer_site">#</T>
- </span> : <>
- <span class="d-inline-block mr-1"><T i18nKey="are_you_sure">#</T></span>
- <span class="pointer d-inline-block mr-1" onClick={linkEvent(this, this.handleTransferSite)}><T i18nKey="yes">#</T></span>
- <span class="pointer d-inline-block" onClick={linkEvent(this, this.handleCancelShowConfirmTransferSite)}><T i18nKey="no">#</T></span>
- </>
- }
+ {!this.state.showConfirmTransferSite ? (
+ <span
+ class="pointer"
+ onClick={linkEvent(
+ this,
+ this.handleShowConfirmTransferSite
+ )}
+ >
+ <T i18nKey="transfer_site">#</T>
+ </span>
+ ) : (
+ <>
+ <span class="d-inline-block mr-1">
+ <T i18nKey="are_you_sure">#</T>
+ </span>
+ <span
+ class="pointer d-inline-block mr-1"
+ onClick={linkEvent(this, this.handleTransferSite)}
+ >
+ <T i18nKey="yes">#</T>
+ </span>
+ <span
+ class="pointer d-inline-block"
+ onClick={linkEvent(
+ this,
+ this.handleCancelShowConfirmTransferSite
+ )}
+ >
+ <T i18nKey="no">#</T>
+ </span>
+ </>
+ )}
</li>
- }
+ )}
</>
- }
+ )}
<li className="list-inline-item">
- <span className="pointer" onClick={linkEvent(this, this.handleViewSource)}><T i18nKey="view_source">#</T></span>
+ <span
+ className="pointer"
+ onClick={linkEvent(this, this.handleViewSource)}
+ >
+ <T i18nKey="view_source">#</T>
+ </span>
</li>
<li className="list-inline-item">
- <Link className="text-muted" to={`/post/${node.comment.post_id}/comment/${node.comment.id}`}><T i18nKey="link">#</T></Link>
+ <Link
+ className="text-muted"
+ to={`/post/${node.comment.post_id}/comment/${node.comment.id}`}
+ >
+ <T i18nKey="link">#</T>
+ </Link>
</li>
- {this.props.markable &&
+ {this.props.markable && (
<li className="list-inline-item">
- <span class="pointer" onClick={linkEvent(this, this.handleMarkRead)}>{node.comment.read ? i18n.t('mark_as_unread') : i18n.t('mark_as_read')}</span>
+ <span
+ class="pointer"
+ onClick={linkEvent(this, this.handleMarkRead)}
+ >
+ {node.comment.read
+ ? i18n.t('mark_as_unread')
+ : i18n.t('mark_as_read')}
+ </span>
</li>
- }
+ )}
</ul>
</div>
- }
+ )}
</div>
- {this.state.showRemoveDialog &&
- <form class="form-inline" onSubmit={linkEvent(this, this.handleModRemoveSubmit)}>
- <input type="text" class="form-control mr-2" placeholder={i18n.t('reason')} value={this.state.removeReason} onInput={linkEvent(this, this.handleModRemoveReasonChange)} />
- <button type="submit" class="btn btn-secondary"><T i18nKey="remove_comment">#</T></button>
+ {this.state.showRemoveDialog && (
+ <form
+ class="form-inline"
+ onSubmit={linkEvent(this, this.handleModRemoveSubmit)}
+ >
+ <input
+ type="text"
+ class="form-control mr-2"
+ placeholder={i18n.t('reason')}
+ value={this.state.removeReason}
+ onInput={linkEvent(this, this.handleModRemoveReasonChange)}
+ />
+ <button type="submit" class="btn btn-secondary">
+ <T i18nKey="remove_comment">#</T>
+ </button>
</form>
- }
- {this.state.showBanDialog &&
+ )}
+ {this.state.showBanDialog && (
<form onSubmit={linkEvent(this, this.handleModBanBothSubmit)}>
<div class="form-group row">
- <label class="col-form-label"><T i18nKey="reason">#</T></label>
- <input type="text" class="form-control mr-2" placeholder={i18n.t('reason')} value={this.state.banReason} onInput={linkEvent(this, this.handleModBanReasonChange)} />
+ <label class="col-form-label">
+ <T i18nKey="reason">#</T>
+ </label>
+ <input
+ type="text"
+ class="form-control mr-2"
+ placeholder={i18n.t('reason')}
+ value={this.state.banReason}
+ onInput={linkEvent(this, this.handleModBanReasonChange)}
+ />
</div>
{/* TODO hold off on expires until later */}
{/* <div class="form-group row"> */}
@@ -242,42 +484,59 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
{/* <input type="date" class="form-control mr-2" placeholder={i18n.t('expires')} value={this.state.banExpires} onInput={linkEvent(this, this.handleModBanExpiresChange)} /> */}
{/* </div> */}
<div class="form-group row">
- <button type="submit" class="btn btn-secondary">{i18n.t('ban')} {node.comment.creator_name}</button>
+ <button type="submit" class="btn btn-secondary">
+ {i18n.t('ban')} {node.comment.creator_name}
+ </button>
</div>
</form>
- }
- {this.state.showReply &&
- <CommentForm
- node={node}
- onReplyCancel={this.handleReplyCancel}
- disabled={this.props.locked}
+ )}
+ {this.state.showReply && (
+ <CommentForm
+ node={node}
+ onReplyCancel={this.handleReplyCancel}
+ disabled={this.props.locked}
/>
- }
- {node.children && !this.state.collapsed &&
- <CommentNodes
- nodes={node.children}
- locked={this.props.locked}
+ )}
+ {node.children && !this.state.collapsed && (
+ <CommentNodes
+ nodes={node.children}
+ locked={this.props.locked}
moderators={this.props.moderators}
admins={this.props.admins}
postCreatorId={this.props.postCreatorId}
/>
- }
+ )}
{/* A collapsed clearfix */}
{this.state.collapsed && <div class="row col-12"></div>}
</div>
- )
+ );
}
get myComment(): boolean {
- return UserService.Instance.user && this.props.node.comment.creator_id == UserService.Instance.user.id;
+ return (
+ UserService.Instance.user &&
+ this.props.node.comment.creator_id == UserService.Instance.user.id
+ );
}
get isMod(): boolean {
- return this.props.moderators && isMod(this.props.moderators.map(m => m.user_id), this.props.node.comment.creator_id);
+ return (
+ this.props.moderators &&
+ isMod(
+ this.props.moderators.map(m => m.user_id),
+ this.props.node.comment.creator_id
+ )
+ );
}
get isAdmin(): boolean {
- return this.props.admins && isMod(this.props.admins.map(a => a.id), this.props.node.comment.creator_id);
+ return (
+ this.props.admins &&
+ isMod(
+ this.props.admins.map(a => a.id),
+ this.props.node.comment.creator_id
+ )
+ );
}
get isPostCreator(): boolean {
@@ -285,38 +544,57 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
}
get canMod(): boolean {
-
if (this.props.admins && this.props.moderators) {
- let adminsThenMods = this.props.admins.map(a => a.id)
- .concat(this.props.moderators.map(m => m.user_id));
-
- return canMod(UserService.Instance.user, adminsThenMods, this.props.node.comment.creator_id);
- } else {
+ let adminsThenMods = this.props.admins
+ .map(a => a.id)
+ .concat(this.props.moderators.map(m => m.user_id));
+
+ return canMod(
+ UserService.Instance.user,
+ adminsThenMods,
+ this.props.node.comment.creator_id
+ );
+ } else {
return false;
}
}
get canAdmin(): boolean {
- return this.props.admins && canMod(UserService.Instance.user, this.props.admins.map(a => a.id), this.props.node.comment.creator_id);
+ return (
+ this.props.admins &&
+ canMod(
+ UserService.Instance.user,
+ this.props.admins.map(a => a.id),
+ this.props.node.comment.creator_id
+ )
+ );
}
get amCommunityCreator(): boolean {
- return this.props.moderators &&
- UserService.Instance.user &&
- (this.props.node.comment.creator_id != UserService.Instance.user.id) &&
- (UserService.Instance.user.id == this.props.moderators[0].user_id);
+ return (
+ this.props.moderators &&
+ UserService.Instance.user &&
+ this.props.node.comment.creator_id != UserService.Instance.user.id &&
+ UserService.Instance.user.id == this.props.moderators[0].user_id
+ );
}
get amSiteCreator(): boolean {
- return this.props.admins &&
- UserService.Instance.user &&
- (this.props.node.comment.creator_id != UserService.Instance.user.id) &&
- (UserService.Instance.user.id == this.props.admins[0].id);
+ return (
+ this.props.admins &&
+ UserService.Instance.user &&
+ this.props.node.comment.creator_id != UserService.Instance.user.id &&
+ UserService.Instance.user.id == this.props.admins[0].id
+ );
}
-
- get commentUnlessRemoved(): string {
+
+ get commentUnlessRemoved(): string {
let node = this.props.node;
- return node.comment.removed ? `*${i18n.t('removed')}*` : node.comment.deleted ? `*${i18n.t('deleted')}*` : node.comment.content;
+ return node.comment.removed
+ ? `*${i18n.t('removed')}*`
+ : node.comment.deleted
+ ? `*${i18n.t('deleted')}*`
+ : node.comment.content;
}
handleReplyClick(i: CommentNode) {
@@ -337,16 +615,19 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
post_id: i.props.node.comment.post_id,
parent_id: i.props.node.comment.parent_id,
deleted: !i.props.node.comment.deleted,
- auth: null
+ auth: null,
};
WebSocketService.Instance.editComment(deleteForm);
}
handleSaveCommentClick(i: CommentNode) {
- let saved = (i.props.node.comment.saved == undefined) ? true : !i.props.node.comment.saved;
+ let saved =
+ i.props.node.comment.saved == undefined
+ ? true
+ : !i.props.node.comment.saved;
let form: SaveCommentForm = {
comment_id: i.props.node.comment.id,
- save: saved
+ save: saved,
};
WebSocketService.Instance.saveComment(form);
@@ -358,13 +639,11 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
this.setState(this.state);
}
-
handleCommentLike(i: CommentNodeI) {
-
let form: CommentLikeForm = {
comment_id: i.comment.id,
post_id: i.comment.post_id,
- score: (i.comment.my_vote == 1) ? 0 : 1
+ score: i.comment.my_vote == 1 ? 0 : 1,
};
WebSocketService.Instance.likeComment(form);
}
@@ -373,7 +652,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
let form: CommentLikeForm = {
comment_id: i.comment.id,
post_id: i.comment.post_id,
- score: (i.comment.my_vote == -1) ? 0 : -1
+ score: i.comment.my_vote == -1 ? 0 : -1,
};
WebSocketService.Instance.likeComment(form);
}
@@ -398,7 +677,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
parent_id: i.props.node.comment.parent_id,
removed: !i.props.node.comment.removed,
reason: i.state.removeReason,
- auth: null
+ auth: null,
};
WebSocketService.Instance.editComment(form);
@@ -414,12 +693,11 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
post_id: i.props.node.comment.post_id,
parent_id: i.props.node.comment.parent_id,
read: !i.props.node.comment.read,
- auth: null
+ auth: null,
};
WebSocketService.Instance.editComment(form);
}
-
handleModBanFromCommunityShow(i: CommentNode) {
i.state.showBanDialog = true;
i.state.banType = BanType.Community;
@@ -499,12 +777,12 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
i.setState(i.state);
}
- handleShowConfirmTransferCommunity(i: CommentNode) {
+ handleShowConfirmTransferCommunity(i: CommentNode) {
i.state.showConfirmTransferCommunity = true;
i.setState(i.state);
}
- handleCancelShowConfirmTransferCommunity(i: CommentNode) {
+ handleCancelShowConfirmTransferCommunity(i: CommentNode) {
i.state.showConfirmTransferCommunity = false;
i.setState(i.state);
}
@@ -519,12 +797,12 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
i.setState(i.state);
}
- handleShowConfirmTransferSite(i: CommentNode) {
+ handleShowConfirmTransferSite(i: CommentNode) {
i.state.showConfirmTransferSite = true;
i.setState(i.state);
}
- handleCancelShowConfirmTransferSite(i: CommentNode) {
+ handleCancelShowConfirmTransferSite(i: CommentNode) {
i.state.showConfirmTransferSite = false;
i.setState(i.state);
}