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';
37 interface CommentNodeState {
40 showRemoveDialog: boolean;
42 showBanDialog: boolean;
46 showConfirmTransferSite: boolean;
47 showConfirmTransferCommunity: boolean;
48 showConfirmAppointAsMod: boolean;
49 showConfirmAppointAsAdmin: boolean;
52 showAdvanced: boolean;
62 interface CommentNodeProps {
68 showContext?: boolean;
69 moderators: Array<CommunityUser>;
70 admins: Array<UserView>;
71 // TODO is this necessary, can't I get it from the node itself?
72 postCreatorId?: number;
73 showCommunity?: boolean;
74 sort?: CommentSortType;
76 enableDownvotes: boolean;
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;
130 className={`comment ${
131 node.comment.parent_id && !this.props.noIndent ? 'ml-1' : ''
135 id={`comment-${node.comment.id}`}
136 className={`details comment-node border-top border-light py-2 ${
137 this.isCommentNew ? 'mark' : ''
140 !this.props.noIndent &&
141 this.props.node.comment.parent_id &&
142 `border-left: 2px ${this.state.borderColor} solid !important`
147 !this.props.noIndent &&
148 this.props.node.comment.parent_id &&
152 <div class="d-flex flex-wrap align-items-center text-muted small">
156 name: node.comment.creator_name,
157 avatar: node.comment.creator_avatar,
158 id: node.comment.creator_id,
159 local: node.comment.creator_local,
160 actor_id: node.comment.creator_actor_id,
161 published: node.comment.creator_published,
167 <div className="badge badge-light d-none d-sm-inline mr-2">
172 <div className="badge badge-light d-none d-sm-inline mr-2">
176 {this.isPostCreator && (
177 <div className="badge badge-light d-none d-sm-inline mr-2">
181 {(node.comment.banned_from_community || node.comment.banned) && (
182 <div className="badge badge-danger mr-2">
186 {this.props.showCommunity && (
188 <span class="mx-1">{i18n.t('to')}</span>
189 <Link class="mr-2" to={`/c/${node.comment.community_name}`}>
190 {node.comment.community_name}
195 class="btn btn-sm text-muted"
196 onClick={linkEvent(this, this.handleCommentCollapse)}
198 {this.state.collapsed ? (
199 <svg class="icon icon-inline">
200 <use xlinkHref="#icon-plus-square"></use>
203 <svg class="icon icon-inline">
204 <use xlinkHref="#icon-minus-square"></use>
208 {/* This is an expanding spacer for mobile */}
209 <div className="mr-lg-4 flex-grow-1 flex-lg-grow-0 unselectable pointer mx-2"></div>
211 className={`btn btn-sm p-0 unselectable pointer ${this.scoreColor}`}
212 onClick={linkEvent(node, this.handleCommentUpvote)}
213 data-tippy-content={this.pointsTippy}
215 <svg class="icon icon-inline mr-1">
216 <use xlinkHref="#icon-zap"></use>
218 <span class="mr-1">{this.state.score}</span>
220 <span className="mr-1">•</span>
222 <MomentTime data={node.comment} />
225 {/* end of user row */}
226 {this.state.showEdit && (
230 onReplyCancel={this.handleReplyCancel}
231 disabled={this.props.locked}
235 {!this.state.showEdit && !this.state.collapsed && (
237 {this.state.viewSource ? (
238 <pre>{this.commentUnlessRemoved}</pre>
242 dangerouslySetInnerHTML={mdToHtml(
243 this.commentUnlessRemoved
247 <div class="d-flex justify-content-between justify-content-lg-start flex-wrap text-muted font-weight-bold">
248 {this.props.showContext && this.linkBtn}
249 {this.props.markable && (
251 class="btn btn-link btn-animate text-muted"
252 onClick={linkEvent(this, this.handleMarkRead)}
255 ? i18n.t('mark_as_unread')
256 : i18n.t('mark_as_read')
259 {this.state.readLoading ? (
263 class={`icon icon-inline ${
264 node.comment.read && 'text-success'
267 <use xlinkHref="#icon-check"></use>
272 {UserService.Instance.user && !this.props.viewOnly && (
275 className={`btn btn-link btn-animate ${
276 this.state.my_vote == 1 ? 'text-info' : 'text-muted'
278 onClick={linkEvent(node, this.handleCommentUpvote)}
279 data-tippy-content={i18n.t('upvote')}
281 <svg class="icon icon-inline">
282 <use xlinkHref="#icon-arrow-up"></use>
284 {this.state.upvotes !== this.state.score && (
285 <span class="ml-1">{this.state.upvotes}</span>
288 {this.props.enableDownvotes && (
290 className={`btn btn-link btn-animate ${
291 this.state.my_vote == -1
295 onClick={linkEvent(node, this.handleCommentDownvote)}
296 data-tippy-content={i18n.t('downvote')}
298 <svg class="icon icon-inline">
299 <use xlinkHref="#icon-arrow-down"></use>
301 {this.state.upvotes !== this.state.score && (
302 <span class="ml-1">{this.state.downvotes}</span>
307 class="btn btn-link btn-animate text-muted"
308 onClick={linkEvent(this, this.handleReplyClick)}
309 data-tippy-content={i18n.t('reply')}
311 <svg class="icon icon-inline">
312 <use xlinkHref="#icon-reply1"></use>
315 {!this.state.showAdvanced ? (
317 className="btn btn-link btn-animate text-muted"
318 onClick={linkEvent(this, this.handleShowAdvanced)}
319 data-tippy-content={i18n.t('more')}
321 <svg class="icon icon-inline">
322 <use xlinkHref="#icon-more-vertical"></use>
327 {!this.myComment && (
328 <button class="btn btn-link btn-animate">
331 to={`/create_private_message?recipient_id=${node.comment.creator_id}`}
332 title={i18n.t('message').toLowerCase()}
335 <use xlinkHref="#icon-mail"></use>
340 {!this.props.showContext && this.linkBtn}
342 class="btn btn-link btn-animate text-muted"
345 this.handleSaveCommentClick
353 {this.state.saveLoading ? (
357 class={`icon icon-inline ${
358 node.comment.saved && 'text-warning'
361 <use xlinkHref="#icon-star"></use>
366 className="btn btn-link btn-animate text-muted"
367 onClick={linkEvent(this, this.handleViewSource)}
368 data-tippy-content={i18n.t('view_source')}
371 class={`icon icon-inline ${
372 this.state.viewSource && 'text-success'
375 <use xlinkHref="#icon-file-text"></use>
381 class="btn btn-link btn-animate text-muted"
382 onClick={linkEvent(this, this.handleEditClick)}
383 data-tippy-content={i18n.t('edit')}
385 <svg class="icon icon-inline">
386 <use xlinkHref="#icon-edit"></use>
390 class="btn btn-link btn-animate text-muted"
393 this.handleDeleteClick
396 !node.comment.deleted
402 class={`icon icon-inline ${
403 node.comment.deleted && 'text-danger'
406 <use xlinkHref="#icon-trash"></use>
411 {/* Admins and mods can remove comments */}
412 {(this.canMod || this.canAdmin) && (
414 {!node.comment.removed ? (
416 class="btn btn-link btn-animate text-muted"
419 this.handleModRemoveShow
426 class="btn btn-link btn-animate text-muted"
429 this.handleModRemoveSubmit
437 {/* Mods can ban from community, and appoint as mods to community */}
441 (!node.comment.banned_from_community ? (
443 class="btn btn-link btn-animate text-muted"
446 this.handleModBanFromCommunityShow
453 class="btn btn-link btn-animate text-muted"
456 this.handleModBanFromCommunitySubmit
462 {!node.comment.banned_from_community &&
463 (!this.state.showConfirmAppointAsMod ? (
465 class="btn btn-link btn-animate text-muted"
468 this.handleShowConfirmAppointAsMod
472 ? i18n.t('remove_as_mod')
473 : i18n.t('appoint_as_mod')}
477 <button class="btn btn-link btn-animate text-muted">
478 {i18n.t('are_you_sure')}
481 class="btn btn-link btn-animate text-muted"
484 this.handleAddModToCommunity
490 class="btn btn-link btn-animate text-muted"
493 this.handleCancelConfirmAppointAsMod
502 {/* Community creators and admins can transfer community to another mod */}
503 {(this.amCommunityCreator || this.canAdmin) &&
505 (!this.state.showConfirmTransferCommunity ? (
507 class="btn btn-link btn-animate text-muted"
510 this.handleShowConfirmTransferCommunity
513 {i18n.t('transfer_community')}
517 <button class="btn btn-link btn-animate text-muted">
518 {i18n.t('are_you_sure')}
521 class="btn btn-link btn-animate text-muted"
524 this.handleTransferCommunity
530 class="btn btn-link btn-animate text-muted"
534 .handleCancelShowConfirmTransferCommunity
541 {/* Admins can ban from all, and appoint other admins */}
545 (!node.comment.banned ? (
547 class="btn btn-link btn-animate text-muted"
550 this.handleModBanShow
553 {i18n.t('ban_from_site')}
557 class="btn btn-link btn-animate text-muted"
560 this.handleModBanSubmit
563 {i18n.t('unban_from_site')}
566 {!node.comment.banned &&
567 (!this.state.showConfirmAppointAsAdmin ? (
569 class="btn btn-link btn-animate text-muted"
572 this.handleShowConfirmAppointAsAdmin
576 ? i18n.t('remove_as_admin')
577 : i18n.t('appoint_as_admin')}
581 <button class="btn btn-link btn-animate text-muted">
582 {i18n.t('are_you_sure')}
585 class="btn btn-link btn-animate text-muted"
594 class="btn btn-link btn-animate text-muted"
597 this.handleCancelConfirmAppointAsAdmin
606 {/* Site Creator can transfer to another admin */}
607 {this.amSiteCreator &&
609 (!this.state.showConfirmTransferSite ? (
611 class="btn btn-link btn-animate text-muted"
614 this.handleShowConfirmTransferSite
617 {i18n.t('transfer_site')}
621 <button class="btn btn-link btn-animate text-muted">
622 {i18n.t('are_you_sure')}
625 class="btn btn-link btn-animate text-muted"
628 this.handleTransferSite
634 class="btn btn-link btn-animate text-muted"
637 this.handleCancelShowConfirmTransferSite
649 {/* end of button group */}
654 {/* end of details */}
655 {this.state.showRemoveDialog && (
658 onSubmit={linkEvent(this, this.handleModRemoveSubmit)}
662 class="form-control mr-2"
663 placeholder={i18n.t('reason')}
664 value={this.state.removeReason}
665 onInput={linkEvent(this, this.handleModRemoveReasonChange)}
667 <button type="submit" class="btn btn-secondary">
668 {i18n.t('remove_comment')}
672 {this.state.showBanDialog && (
673 <form onSubmit={linkEvent(this, this.handleModBanBothSubmit)}>
674 <div class="form-group row">
675 <label class="col-form-label">{i18n.t('reason')}</label>
678 class="form-control mr-2"
679 placeholder={i18n.t('reason')}
680 value={this.state.banReason}
681 onInput={linkEvent(this, this.handleModBanReasonChange)}
684 {/* TODO hold off on expires until later */}
685 {/* <div class="form-group row"> */}
686 {/* <label class="col-form-label">Expires</label> */}
687 {/* <input type="date" class="form-control mr-2" placeholder={i18n.t('expires')} value={this.state.banExpires} onInput={linkEvent(this, this.handleModBanExpiresChange)} /> */}
689 <div class="form-group row">
690 <button type="submit" class="btn btn-secondary">
691 {i18n.t('ban')} {node.comment.creator_name}
696 {this.state.showReply && (
699 onReplyCancel={this.handleReplyCancel}
700 disabled={this.props.locked}
704 {node.children && !this.state.collapsed && (
706 nodes={node.children}
707 locked={this.props.locked}
708 moderators={this.props.moderators}
709 admins={this.props.admins}
710 postCreatorId={this.props.postCreatorId}
711 sort={this.props.sort}
712 sortType={this.props.sortType}
713 enableDownvotes={this.props.enableDownvotes}
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}`;