1 import { Component, linkEvent } from 'inferno';
2 import { Link } from 'inferno-router';
4 CommentNode as CommentNodeI,
6 CommentForm as CommentFormI,
13 AddModToCommunityForm,
15 TransferCommunityForm,
20 } from '../interfaces';
21 import { WebSocketService, UserService } from '../services';
30 import moment from 'moment';
31 import { MomentTime } from './moment-time';
32 import { CommentForm } from './comment-form';
33 import { CommentNodes } from './comment-nodes';
34 import { UserListing } from './user-listing';
35 import { i18n } from '../i18next';
36 import { CakeDay } from './cake-day';
38 interface CommentNodeState {
41 showRemoveDialog: boolean;
43 showBanDialog: boolean;
47 showConfirmTransferSite: boolean;
48 showConfirmTransferCommunity: boolean;
49 showConfirmAppointAsMod: boolean;
50 showConfirmAppointAsAdmin: boolean;
53 showAdvanced: boolean;
63 interface CommentNodeProps {
69 showContext?: boolean;
70 moderators: Array<CommunityUser>;
71 admins: Array<UserView>;
72 // TODO is this necessary, can't I get it from the node itself?
73 postCreatorId?: number;
74 showCommunity?: boolean;
75 sort?: CommentSortType;
79 export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
80 private emptyState: CommentNodeState = {
83 showRemoveDialog: false,
88 banType: BanType.Community,
92 showConfirmTransferSite: false,
93 showConfirmTransferCommunity: false,
94 showConfirmAppointAsMod: false,
95 showConfirmAppointAsAdmin: false,
96 my_vote: this.props.node.comment.my_vote,
97 score: this.props.node.comment.score,
98 upvotes: this.props.node.comment.upvotes,
99 downvotes: this.props.node.comment.downvotes,
100 borderColor: this.props.node.comment.depth
101 ? colorList[this.props.node.comment.depth % colorList.length]
107 constructor(props: any, context: any) {
108 super(props, context);
110 this.state = this.emptyState;
111 this.handleReplyCancel = this.handleReplyCancel.bind(this);
112 this.handleCommentUpvote = this.handleCommentUpvote.bind(this);
113 this.handleCommentDownvote = this.handleCommentDownvote.bind(this);
116 componentWillReceiveProps(nextProps: CommentNodeProps) {
117 this.state.my_vote = nextProps.node.comment.my_vote;
118 this.state.upvotes = nextProps.node.comment.upvotes;
119 this.state.downvotes = nextProps.node.comment.downvotes;
120 this.state.score = nextProps.node.comment.score;
121 this.state.readLoading = false;
122 this.state.saveLoading = false;
123 this.setState(this.state);
127 let node = this.props.node;
128 const { creator_name, creator_published } = node.comment;
131 className={`comment ${
132 node.comment.parent_id && !this.props.noIndent ? 'ml-1' : ''
136 id={`comment-${node.comment.id}`}
137 className={`details comment-node border-top border-light py-2 ${
138 this.isCommentNew ? 'mark' : ''
141 !this.props.noIndent &&
142 this.props.node.comment.parent_id &&
143 `border-left: 2px ${this.state.borderColor} solid !important`
148 !this.props.noIndent &&
149 this.props.node.comment.parent_id &&
153 <div class="d-flex flex-wrap align-items-center text-muted small">
157 name: node.comment.creator_name,
158 avatar: node.comment.creator_avatar,
159 id: node.comment.creator_id,
160 local: node.comment.creator_local,
161 actor_id: node.comment.creator_actor_id,
167 creator_name={creator_name}
168 creator_published={creator_published}
172 <div className="badge badge-light d-none d-sm-inline mr-2">
177 <div className="badge badge-light d-none d-sm-inline mr-2">
181 {this.isPostCreator && (
182 <div className="badge badge-light d-none d-sm-inline mr-2">
186 {(node.comment.banned_from_community || node.comment.banned) && (
187 <div className="badge badge-danger mr-2">
191 {this.props.showCommunity && (
193 <span class="mx-1">{i18n.t('to')}</span>
194 <Link class="mr-2" to={`/c/${node.comment.community_name}`}>
195 {node.comment.community_name}
200 className="mr-lg-4 flex-grow-1 flex-lg-grow-0 unselectable pointer mx-2"
201 onClick={linkEvent(this, this.handleCommentCollapse)}
203 {this.state.collapsed ? (
204 <svg class="icon icon-inline">
205 <use xlinkHref="#icon-plus-square"></use>
208 <svg class="icon icon-inline">
209 <use xlinkHref="#icon-minus-square"></use>
214 className={`unselectable pointer ${this.scoreColor}`}
215 onClick={linkEvent(node, this.handleCommentUpvote)}
216 data-tippy-content={this.pointsTippy}
218 <svg class="icon icon-inline mr-1">
219 <use xlinkHref="#icon-zap"></use>
221 <span class="mr-1">{this.state.score}</span>
223 <span className="mr-1">•</span>
225 <MomentTime data={node.comment} />
228 {/* end of user row */}
229 {this.state.showEdit && (
233 onReplyCancel={this.handleReplyCancel}
234 disabled={this.props.locked}
237 {!this.state.showEdit && !this.state.collapsed && (
239 {this.state.viewSource ? (
240 <pre>{this.commentUnlessRemoved}</pre>
244 dangerouslySetInnerHTML={mdToHtml(
245 this.commentUnlessRemoved
249 <div class="d-flex justify-content-between justify-content-lg-start flex-wrap text-muted font-weight-bold">
250 {this.props.showContext && this.linkBtn}
251 {this.props.markable && (
253 class="btn btn-link btn-animate text-muted"
254 onClick={linkEvent(this, this.handleMarkRead)}
257 ? i18n.t('mark_as_unread')
258 : i18n.t('mark_as_read')
261 {this.state.readLoading ? (
265 class={`icon icon-inline ${
266 node.comment.read && 'text-success'
269 <use xlinkHref="#icon-check"></use>
274 {UserService.Instance.user && !this.props.viewOnly && (
277 className={`btn btn-link btn-animate ${
278 this.state.my_vote == 1 ? 'text-info' : 'text-muted'
280 onClick={linkEvent(node, this.handleCommentUpvote)}
281 data-tippy-content={i18n.t('upvote')}
283 <svg class="icon icon-inline">
284 <use xlinkHref="#icon-arrow-up"></use>
286 {this.state.upvotes !== this.state.score && (
287 <span class="ml-1">{this.state.upvotes}</span>
290 {WebSocketService.Instance.site.enable_downvotes && (
292 className={`btn btn-link btn-animate ${
293 this.state.my_vote == -1
297 onClick={linkEvent(node, this.handleCommentDownvote)}
298 data-tippy-content={i18n.t('downvote')}
300 <svg class="icon icon-inline">
301 <use xlinkHref="#icon-arrow-down"></use>
303 {this.state.upvotes !== this.state.score && (
304 <span class="ml-1">{this.state.downvotes}</span>
309 class="btn btn-link btn-animate text-muted"
310 onClick={linkEvent(this, this.handleReplyClick)}
311 data-tippy-content={i18n.t('reply')}
313 <svg class="icon icon-inline">
314 <use xlinkHref="#icon-reply1"></use>
317 {!this.state.showAdvanced ? (
319 className="btn btn-link btn-animate text-muted"
320 onClick={linkEvent(this, this.handleShowAdvanced)}
321 data-tippy-content={i18n.t('more')}
323 <svg class="icon icon-inline">
324 <use xlinkHref="#icon-more-vertical"></use>
329 {!this.myComment && (
330 <button class="btn btn-link btn-animate">
333 to={`/create_private_message?recipient_id=${node.comment.creator_id}`}
334 title={i18n.t('message').toLowerCase()}
337 <use xlinkHref="#icon-mail"></use>
342 {!this.props.showContext && this.linkBtn}
344 class="btn btn-link btn-animate text-muted"
347 this.handleSaveCommentClick
355 {this.state.saveLoading ? (
359 class={`icon icon-inline ${
360 node.comment.saved && 'text-warning'
363 <use xlinkHref="#icon-star"></use>
368 className="btn btn-link btn-animate text-muted"
369 onClick={linkEvent(this, this.handleViewSource)}
370 data-tippy-content={i18n.t('view_source')}
373 class={`icon icon-inline ${
374 this.state.viewSource && 'text-success'
377 <use xlinkHref="#icon-file-text"></use>
383 class="btn btn-link btn-animate text-muted"
384 onClick={linkEvent(this, this.handleEditClick)}
385 data-tippy-content={i18n.t('edit')}
387 <svg class="icon icon-inline">
388 <use xlinkHref="#icon-edit"></use>
392 class="btn btn-link btn-animate text-muted"
395 this.handleDeleteClick
398 !node.comment.deleted
404 class={`icon icon-inline ${
405 node.comment.deleted && 'text-danger'
408 <use xlinkHref="#icon-trash"></use>
413 {/* Admins and mods can remove comments */}
414 {(this.canMod || this.canAdmin) && (
416 {!node.comment.removed ? (
418 class="btn btn-link btn-animate text-muted"
421 this.handleModRemoveShow
428 class="btn btn-link btn-animate text-muted"
431 this.handleModRemoveSubmit
439 {/* Mods can ban from community, and appoint as mods to community */}
443 (!node.comment.banned_from_community ? (
445 class="btn btn-link btn-animate text-muted"
448 this.handleModBanFromCommunityShow
455 class="btn btn-link btn-animate text-muted"
458 this.handleModBanFromCommunitySubmit
464 {!node.comment.banned_from_community &&
465 (!this.state.showConfirmAppointAsMod ? (
467 class="btn btn-link btn-animate text-muted"
470 this.handleShowConfirmAppointAsMod
474 ? i18n.t('remove_as_mod')
475 : i18n.t('appoint_as_mod')}
479 <button class="btn btn-link btn-animate text-muted">
480 {i18n.t('are_you_sure')}
483 class="btn btn-link btn-animate text-muted"
486 this.handleAddModToCommunity
492 class="btn btn-link btn-animate text-muted"
495 this.handleCancelConfirmAppointAsMod
504 {/* Community creators and admins can transfer community to another mod */}
505 {(this.amCommunityCreator || this.canAdmin) &&
507 (!this.state.showConfirmTransferCommunity ? (
509 class="btn btn-link btn-animate text-muted"
512 this.handleShowConfirmTransferCommunity
515 {i18n.t('transfer_community')}
519 <button class="btn btn-link btn-animate text-muted">
520 {i18n.t('are_you_sure')}
523 class="btn btn-link btn-animate text-muted"
526 this.handleTransferCommunity
532 class="btn btn-link btn-animate text-muted"
536 .handleCancelShowConfirmTransferCommunity
543 {/* Admins can ban from all, and appoint other admins */}
547 (!node.comment.banned ? (
549 class="btn btn-link btn-animate text-muted"
552 this.handleModBanShow
555 {i18n.t('ban_from_site')}
559 class="btn btn-link btn-animate text-muted"
562 this.handleModBanSubmit
565 {i18n.t('unban_from_site')}
568 {!node.comment.banned &&
569 (!this.state.showConfirmAppointAsAdmin ? (
571 class="btn btn-link btn-animate text-muted"
574 this.handleShowConfirmAppointAsAdmin
578 ? i18n.t('remove_as_admin')
579 : i18n.t('appoint_as_admin')}
583 <button class="btn btn-link btn-animate text-muted">
584 {i18n.t('are_you_sure')}
587 class="btn btn-link btn-animate text-muted"
596 class="btn btn-link btn-animate text-muted"
599 this.handleCancelConfirmAppointAsAdmin
608 {/* Site Creator can transfer to another admin */}
609 {this.amSiteCreator &&
611 (!this.state.showConfirmTransferSite ? (
613 class="btn btn-link btn-animate text-muted"
616 this.handleShowConfirmTransferSite
619 {i18n.t('transfer_site')}
623 <button class="btn btn-link btn-animate text-muted">
624 {i18n.t('are_you_sure')}
627 class="btn btn-link btn-animate text-muted"
630 this.handleTransferSite
636 class="btn btn-link btn-animate text-muted"
639 this.handleCancelShowConfirmTransferSite
651 {/* end of button group */}
656 {/* end of details */}
657 {this.state.showRemoveDialog && (
660 onSubmit={linkEvent(this, this.handleModRemoveSubmit)}
664 class="form-control mr-2"
665 placeholder={i18n.t('reason')}
666 value={this.state.removeReason}
667 onInput={linkEvent(this, this.handleModRemoveReasonChange)}
669 <button type="submit" class="btn btn-secondary">
670 {i18n.t('remove_comment')}
674 {this.state.showBanDialog && (
675 <form onSubmit={linkEvent(this, this.handleModBanBothSubmit)}>
676 <div class="form-group row">
677 <label class="col-form-label">{i18n.t('reason')}</label>
680 class="form-control mr-2"
681 placeholder={i18n.t('reason')}
682 value={this.state.banReason}
683 onInput={linkEvent(this, this.handleModBanReasonChange)}
686 {/* TODO hold off on expires until later */}
687 {/* <div class="form-group row"> */}
688 {/* <label class="col-form-label">Expires</label> */}
689 {/* <input type="date" class="form-control mr-2" placeholder={i18n.t('expires')} value={this.state.banExpires} onInput={linkEvent(this, this.handleModBanExpiresChange)} /> */}
691 <div class="form-group row">
692 <button type="submit" class="btn btn-secondary">
693 {i18n.t('ban')} {node.comment.creator_name}
698 {this.state.showReply && (
701 onReplyCancel={this.handleReplyCancel}
702 disabled={this.props.locked}
705 {node.children && !this.state.collapsed && (
707 nodes={node.children}
708 locked={this.props.locked}
709 moderators={this.props.moderators}
710 admins={this.props.admins}
711 postCreatorId={this.props.postCreatorId}
712 sort={this.props.sort}
713 sortType={this.props.sortType}
716 {/* A collapsed clearfix */}
717 {this.state.collapsed && <div class="row col-12"></div>}
723 let node = this.props.node;
726 class="btn btn-link btn-animate text-muted"
727 to={`/post/${node.comment.post_id}/comment/${node.comment.id}`}
728 title={this.props.showContext ? i18n.t('show_context') : i18n.t('link')}
730 <svg class="icon icon-inline">
731 <use xlinkHref="#icon-link"></use>
739 <svg class="icon icon-spinner spin">
740 <use xlinkHref="#icon-spinner"></use>
745 get myComment(): boolean {
747 UserService.Instance.user &&
748 this.props.node.comment.creator_id == UserService.Instance.user.id
752 get isMod(): boolean {
754 this.props.moderators &&
756 this.props.moderators.map(m => m.user_id),
757 this.props.node.comment.creator_id
762 get isAdmin(): boolean {
766 this.props.admins.map(a => a.id),
767 this.props.node.comment.creator_id
772 get isPostCreator(): boolean {
773 return this.props.node.comment.creator_id == this.props.postCreatorId;
776 get canMod(): boolean {
777 if (this.props.admins && this.props.moderators) {
778 let adminsThenMods = this.props.admins
780 .concat(this.props.moderators.map(m => m.user_id));
783 UserService.Instance.user,
785 this.props.node.comment.creator_id
792 get canAdmin(): boolean {
796 UserService.Instance.user,
797 this.props.admins.map(a => a.id),
798 this.props.node.comment.creator_id
803 get amCommunityCreator(): boolean {
805 this.props.moderators &&
806 UserService.Instance.user &&
807 this.props.node.comment.creator_id != UserService.Instance.user.id &&
808 UserService.Instance.user.id == this.props.moderators[0].user_id
812 get amSiteCreator(): boolean {
815 UserService.Instance.user &&
816 this.props.node.comment.creator_id != UserService.Instance.user.id &&
817 UserService.Instance.user.id == this.props.admins[0].id
821 get commentUnlessRemoved(): string {
822 let node = this.props.node;
823 return node.comment.removed
824 ? `*${i18n.t('removed')}*`
825 : node.comment.deleted
826 ? `*${i18n.t('deleted')}*`
827 : node.comment.content;
830 handleReplyClick(i: CommentNode) {
831 i.state.showReply = true;
835 handleEditClick(i: CommentNode) {
836 i.state.showEdit = true;
840 handleDeleteClick(i: CommentNode) {
841 let deleteForm: CommentFormI = {
842 content: i.props.node.comment.content,
843 edit_id: i.props.node.comment.id,
844 creator_id: i.props.node.comment.creator_id,
845 post_id: i.props.node.comment.post_id,
846 parent_id: i.props.node.comment.parent_id,
847 deleted: !i.props.node.comment.deleted,
850 WebSocketService.Instance.editComment(deleteForm);
853 handleSaveCommentClick(i: CommentNode) {
855 i.props.node.comment.saved == undefined
857 : !i.props.node.comment.saved;
858 let form: SaveCommentForm = {
859 comment_id: i.props.node.comment.id,
863 WebSocketService.Instance.saveComment(form);
865 i.state.saveLoading = true;
866 i.setState(this.state);
869 handleReplyCancel() {
870 this.state.showReply = false;
871 this.state.showEdit = false;
872 this.setState(this.state);
875 handleCommentUpvote(i: CommentNodeI) {
876 let new_vote = this.state.my_vote == 1 ? 0 : 1;
878 if (this.state.my_vote == 1) {
880 this.state.upvotes--;
881 } else if (this.state.my_vote == -1) {
882 this.state.downvotes--;
883 this.state.upvotes++;
884 this.state.score += 2;
886 this.state.upvotes++;
890 this.state.my_vote = new_vote;
892 let form: CommentLikeForm = {
893 comment_id: i.comment.id,
894 post_id: i.comment.post_id,
895 score: this.state.my_vote,
898 WebSocketService.Instance.likeComment(form);
899 this.setState(this.state);
903 handleCommentDownvote(i: CommentNodeI) {
904 let new_vote = this.state.my_vote == -1 ? 0 : -1;
906 if (this.state.my_vote == 1) {
907 this.state.score -= 2;
908 this.state.upvotes--;
909 this.state.downvotes++;
910 } else if (this.state.my_vote == -1) {
911 this.state.downvotes--;
914 this.state.downvotes++;
918 this.state.my_vote = new_vote;
920 let form: CommentLikeForm = {
921 comment_id: i.comment.id,
922 post_id: i.comment.post_id,
923 score: this.state.my_vote,
926 WebSocketService.Instance.likeComment(form);
927 this.setState(this.state);
931 handleModRemoveShow(i: CommentNode) {
932 i.state.showRemoveDialog = true;
936 handleModRemoveReasonChange(i: CommentNode, event: any) {
937 i.state.removeReason = event.target.value;
941 handleModRemoveSubmit(i: CommentNode) {
942 event.preventDefault();
943 let form: CommentFormI = {
944 content: i.props.node.comment.content,
945 edit_id: i.props.node.comment.id,
946 creator_id: i.props.node.comment.creator_id,
947 post_id: i.props.node.comment.post_id,
948 parent_id: i.props.node.comment.parent_id,
949 removed: !i.props.node.comment.removed,
950 reason: i.state.removeReason,
953 WebSocketService.Instance.editComment(form);
955 i.state.showRemoveDialog = false;
959 handleMarkRead(i: CommentNode) {
960 // if it has a user_mention_id field, then its a mention
961 if (i.props.node.comment.user_mention_id) {
962 let form: EditUserMentionForm = {
963 user_mention_id: i.props.node.comment.user_mention_id,
964 read: !i.props.node.comment.read,
966 WebSocketService.Instance.editUserMention(form);
968 let form: CommentFormI = {
969 content: i.props.node.comment.content,
970 edit_id: i.props.node.comment.id,
971 creator_id: i.props.node.comment.creator_id,
972 post_id: i.props.node.comment.post_id,
973 parent_id: i.props.node.comment.parent_id,
974 read: !i.props.node.comment.read,
977 WebSocketService.Instance.editComment(form);
980 i.state.readLoading = true;
981 i.setState(this.state);
984 handleModBanFromCommunityShow(i: CommentNode) {
985 i.state.showBanDialog = !i.state.showBanDialog;
986 i.state.banType = BanType.Community;
990 handleModBanShow(i: CommentNode) {
991 i.state.showBanDialog = !i.state.showBanDialog;
992 i.state.banType = BanType.Site;
996 handleModBanReasonChange(i: CommentNode, event: any) {
997 i.state.banReason = event.target.value;
1001 handleModBanExpiresChange(i: CommentNode, event: any) {
1002 i.state.banExpires = event.target.value;
1003 i.setState(i.state);
1006 handleModBanFromCommunitySubmit(i: CommentNode) {
1007 i.state.banType = BanType.Community;
1008 i.setState(i.state);
1009 i.handleModBanBothSubmit(i);
1012 handleModBanSubmit(i: CommentNode) {
1013 i.state.banType = BanType.Site;
1014 i.setState(i.state);
1015 i.handleModBanBothSubmit(i);
1018 handleModBanBothSubmit(i: CommentNode) {
1019 event.preventDefault();
1021 if (i.state.banType == BanType.Community) {
1022 let form: BanFromCommunityForm = {
1023 user_id: i.props.node.comment.creator_id,
1024 community_id: i.props.node.comment.community_id,
1025 ban: !i.props.node.comment.banned_from_community,
1026 reason: i.state.banReason,
1027 expires: getUnixTime(i.state.banExpires),
1029 WebSocketService.Instance.banFromCommunity(form);
1031 let form: BanUserForm = {
1032 user_id: i.props.node.comment.creator_id,
1033 ban: !i.props.node.comment.banned,
1034 reason: i.state.banReason,
1035 expires: getUnixTime(i.state.banExpires),
1037 WebSocketService.Instance.banUser(form);
1040 i.state.showBanDialog = false;
1041 i.setState(i.state);
1044 handleShowConfirmAppointAsMod(i: CommentNode) {
1045 i.state.showConfirmAppointAsMod = true;
1046 i.setState(i.state);
1049 handleCancelConfirmAppointAsMod(i: CommentNode) {
1050 i.state.showConfirmAppointAsMod = false;
1051 i.setState(i.state);
1054 handleAddModToCommunity(i: CommentNode) {
1055 let form: AddModToCommunityForm = {
1056 user_id: i.props.node.comment.creator_id,
1057 community_id: i.props.node.comment.community_id,
1060 WebSocketService.Instance.addModToCommunity(form);
1061 i.state.showConfirmAppointAsMod = false;
1062 i.setState(i.state);
1065 handleShowConfirmAppointAsAdmin(i: CommentNode) {
1066 i.state.showConfirmAppointAsAdmin = true;
1067 i.setState(i.state);
1070 handleCancelConfirmAppointAsAdmin(i: CommentNode) {
1071 i.state.showConfirmAppointAsAdmin = false;
1072 i.setState(i.state);
1075 handleAddAdmin(i: CommentNode) {
1076 let form: AddAdminForm = {
1077 user_id: i.props.node.comment.creator_id,
1080 WebSocketService.Instance.addAdmin(form);
1081 i.state.showConfirmAppointAsAdmin = false;
1082 i.setState(i.state);
1085 handleShowConfirmTransferCommunity(i: CommentNode) {
1086 i.state.showConfirmTransferCommunity = true;
1087 i.setState(i.state);
1090 handleCancelShowConfirmTransferCommunity(i: CommentNode) {
1091 i.state.showConfirmTransferCommunity = false;
1092 i.setState(i.state);
1095 handleTransferCommunity(i: CommentNode) {
1096 let form: TransferCommunityForm = {
1097 community_id: i.props.node.comment.community_id,
1098 user_id: i.props.node.comment.creator_id,
1100 WebSocketService.Instance.transferCommunity(form);
1101 i.state.showConfirmTransferCommunity = false;
1102 i.setState(i.state);
1105 handleShowConfirmTransferSite(i: CommentNode) {
1106 i.state.showConfirmTransferSite = true;
1107 i.setState(i.state);
1110 handleCancelShowConfirmTransferSite(i: CommentNode) {
1111 i.state.showConfirmTransferSite = false;
1112 i.setState(i.state);
1115 handleTransferSite(i: CommentNode) {
1116 let form: TransferSiteForm = {
1117 user_id: i.props.node.comment.creator_id,
1119 WebSocketService.Instance.transferSite(form);
1120 i.state.showConfirmTransferSite = false;
1121 i.setState(i.state);
1124 get isCommentNew(): boolean {
1125 let now = moment.utc().subtract(10, 'minutes');
1126 let then = moment.utc(this.props.node.comment.published);
1127 return now.isBefore(then);
1130 handleCommentCollapse(i: CommentNode) {
1131 i.state.collapsed = !i.state.collapsed;
1132 i.setState(i.state);
1135 handleViewSource(i: CommentNode) {
1136 i.state.viewSource = !i.state.viewSource;
1137 i.setState(i.state);
1140 handleShowAdvanced(i: CommentNode) {
1141 i.state.showAdvanced = !i.state.showAdvanced;
1142 i.setState(i.state);
1147 if (this.state.my_vote == 1) {
1149 } else if (this.state.my_vote == -1) {
1150 return 'text-danger';
1152 return 'text-muted';
1156 get pointsTippy(): string {
1157 let points = i18n.t('number_of_points', {
1158 count: this.state.score,
1161 let upvotes = i18n.t('number_of_upvotes', {
1162 count: this.state.upvotes,
1165 let downvotes = i18n.t('number_of_downvotes', {
1166 count: this.state.downvotes,
1169 return `${points} • ${upvotes} • ${downvotes}`;