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}
234 {!this.state.showEdit && !this.state.collapsed && (
236 {this.state.viewSource ? (
237 <pre>{this.commentUnlessRemoved}</pre>
241 dangerouslySetInnerHTML={mdToHtml(
242 this.commentUnlessRemoved
246 <div class="d-flex justify-content-between justify-content-lg-start flex-wrap text-muted font-weight-bold">
247 {this.props.showContext && this.linkBtn}
248 {this.props.markable && (
250 class="btn btn-link btn-animate text-muted"
251 onClick={linkEvent(this, this.handleMarkRead)}
254 ? i18n.t('mark_as_unread')
255 : i18n.t('mark_as_read')
258 {this.state.readLoading ? (
262 class={`icon icon-inline ${
263 node.comment.read && 'text-success'
266 <use xlinkHref="#icon-check"></use>
271 {UserService.Instance.user && !this.props.viewOnly && (
274 className={`btn btn-link btn-animate ${
275 this.state.my_vote == 1 ? 'text-info' : 'text-muted'
277 onClick={linkEvent(node, this.handleCommentUpvote)}
278 data-tippy-content={i18n.t('upvote')}
280 <svg class="icon icon-inline">
281 <use xlinkHref="#icon-arrow-up"></use>
283 {this.state.upvotes !== this.state.score && (
284 <span class="ml-1">{this.state.upvotes}</span>
287 {this.props.enableDownvotes && (
289 className={`btn btn-link btn-animate ${
290 this.state.my_vote == -1
294 onClick={linkEvent(node, this.handleCommentDownvote)}
295 data-tippy-content={i18n.t('downvote')}
297 <svg class="icon icon-inline">
298 <use xlinkHref="#icon-arrow-down"></use>
300 {this.state.upvotes !== this.state.score && (
301 <span class="ml-1">{this.state.downvotes}</span>
306 class="btn btn-link btn-animate text-muted"
307 onClick={linkEvent(this, this.handleReplyClick)}
308 data-tippy-content={i18n.t('reply')}
310 <svg class="icon icon-inline">
311 <use xlinkHref="#icon-reply1"></use>
314 {!this.state.showAdvanced ? (
316 className="btn btn-link btn-animate text-muted"
317 onClick={linkEvent(this, this.handleShowAdvanced)}
318 data-tippy-content={i18n.t('more')}
320 <svg class="icon icon-inline">
321 <use xlinkHref="#icon-more-vertical"></use>
326 {!this.myComment && (
327 <button class="btn btn-link btn-animate">
330 to={`/create_private_message?recipient_id=${node.comment.creator_id}`}
331 title={i18n.t('message').toLowerCase()}
334 <use xlinkHref="#icon-mail"></use>
339 {!this.props.showContext && this.linkBtn}
341 class="btn btn-link btn-animate text-muted"
344 this.handleSaveCommentClick
352 {this.state.saveLoading ? (
356 class={`icon icon-inline ${
357 node.comment.saved && 'text-warning'
360 <use xlinkHref="#icon-star"></use>
365 className="btn btn-link btn-animate text-muted"
366 onClick={linkEvent(this, this.handleViewSource)}
367 data-tippy-content={i18n.t('view_source')}
370 class={`icon icon-inline ${
371 this.state.viewSource && 'text-success'
374 <use xlinkHref="#icon-file-text"></use>
380 class="btn btn-link btn-animate text-muted"
381 onClick={linkEvent(this, this.handleEditClick)}
382 data-tippy-content={i18n.t('edit')}
384 <svg class="icon icon-inline">
385 <use xlinkHref="#icon-edit"></use>
389 class="btn btn-link btn-animate text-muted"
392 this.handleDeleteClick
395 !node.comment.deleted
401 class={`icon icon-inline ${
402 node.comment.deleted && 'text-danger'
405 <use xlinkHref="#icon-trash"></use>
410 {/* Admins and mods can remove comments */}
411 {(this.canMod || this.canAdmin) && (
413 {!node.comment.removed ? (
415 class="btn btn-link btn-animate text-muted"
418 this.handleModRemoveShow
425 class="btn btn-link btn-animate text-muted"
428 this.handleModRemoveSubmit
436 {/* Mods can ban from community, and appoint as mods to community */}
440 (!node.comment.banned_from_community ? (
442 class="btn btn-link btn-animate text-muted"
445 this.handleModBanFromCommunityShow
452 class="btn btn-link btn-animate text-muted"
455 this.handleModBanFromCommunitySubmit
461 {!node.comment.banned_from_community &&
462 (!this.state.showConfirmAppointAsMod ? (
464 class="btn btn-link btn-animate text-muted"
467 this.handleShowConfirmAppointAsMod
471 ? i18n.t('remove_as_mod')
472 : i18n.t('appoint_as_mod')}
476 <button class="btn btn-link btn-animate text-muted">
477 {i18n.t('are_you_sure')}
480 class="btn btn-link btn-animate text-muted"
483 this.handleAddModToCommunity
489 class="btn btn-link btn-animate text-muted"
492 this.handleCancelConfirmAppointAsMod
501 {/* Community creators and admins can transfer community to another mod */}
502 {(this.amCommunityCreator || this.canAdmin) &&
504 (!this.state.showConfirmTransferCommunity ? (
506 class="btn btn-link btn-animate text-muted"
509 this.handleShowConfirmTransferCommunity
512 {i18n.t('transfer_community')}
516 <button class="btn btn-link btn-animate text-muted">
517 {i18n.t('are_you_sure')}
520 class="btn btn-link btn-animate text-muted"
523 this.handleTransferCommunity
529 class="btn btn-link btn-animate text-muted"
533 .handleCancelShowConfirmTransferCommunity
540 {/* Admins can ban from all, and appoint other admins */}
544 (!node.comment.banned ? (
546 class="btn btn-link btn-animate text-muted"
549 this.handleModBanShow
552 {i18n.t('ban_from_site')}
556 class="btn btn-link btn-animate text-muted"
559 this.handleModBanSubmit
562 {i18n.t('unban_from_site')}
565 {!node.comment.banned &&
566 (!this.state.showConfirmAppointAsAdmin ? (
568 class="btn btn-link btn-animate text-muted"
571 this.handleShowConfirmAppointAsAdmin
575 ? i18n.t('remove_as_admin')
576 : i18n.t('appoint_as_admin')}
580 <button class="btn btn-link btn-animate text-muted">
581 {i18n.t('are_you_sure')}
584 class="btn btn-link btn-animate text-muted"
593 class="btn btn-link btn-animate text-muted"
596 this.handleCancelConfirmAppointAsAdmin
605 {/* Site Creator can transfer to another admin */}
606 {this.amSiteCreator &&
608 (!this.state.showConfirmTransferSite ? (
610 class="btn btn-link btn-animate text-muted"
613 this.handleShowConfirmTransferSite
616 {i18n.t('transfer_site')}
620 <button class="btn btn-link btn-animate text-muted">
621 {i18n.t('are_you_sure')}
624 class="btn btn-link btn-animate text-muted"
627 this.handleTransferSite
633 class="btn btn-link btn-animate text-muted"
636 this.handleCancelShowConfirmTransferSite
648 {/* end of button group */}
653 {/* end of details */}
654 {this.state.showRemoveDialog && (
657 onSubmit={linkEvent(this, this.handleModRemoveSubmit)}
661 class="form-control mr-2"
662 placeholder={i18n.t('reason')}
663 value={this.state.removeReason}
664 onInput={linkEvent(this, this.handleModRemoveReasonChange)}
666 <button type="submit" class="btn btn-secondary">
667 {i18n.t('remove_comment')}
671 {this.state.showBanDialog && (
672 <form onSubmit={linkEvent(this, this.handleModBanBothSubmit)}>
673 <div class="form-group row">
674 <label class="col-form-label">{i18n.t('reason')}</label>
677 class="form-control mr-2"
678 placeholder={i18n.t('reason')}
679 value={this.state.banReason}
680 onInput={linkEvent(this, this.handleModBanReasonChange)}
683 {/* TODO hold off on expires until later */}
684 {/* <div class="form-group row"> */}
685 {/* <label class="col-form-label">Expires</label> */}
686 {/* <input type="date" class="form-control mr-2" placeholder={i18n.t('expires')} value={this.state.banExpires} onInput={linkEvent(this, this.handleModBanExpiresChange)} /> */}
688 <div class="form-group row">
689 <button type="submit" class="btn btn-secondary">
690 {i18n.t('ban')} {node.comment.creator_name}
695 {this.state.showReply && (
698 onReplyCancel={this.handleReplyCancel}
699 disabled={this.props.locked}
702 {node.children && !this.state.collapsed && (
704 nodes={node.children}
705 locked={this.props.locked}
706 moderators={this.props.moderators}
707 admins={this.props.admins}
708 postCreatorId={this.props.postCreatorId}
709 sort={this.props.sort}
710 sortType={this.props.sortType}
711 enableDownvotes={this.props.enableDownvotes}
714 {/* A collapsed clearfix */}
715 {this.state.collapsed && <div class="row col-12"></div>}
721 let node = this.props.node;
724 class="btn btn-link btn-animate text-muted"
725 to={`/post/${node.comment.post_id}/comment/${node.comment.id}`}
726 title={this.props.showContext ? i18n.t('show_context') : i18n.t('link')}
728 <svg class="icon icon-inline">
729 <use xlinkHref="#icon-link"></use>
737 <svg class="icon icon-spinner spin">
738 <use xlinkHref="#icon-spinner"></use>
743 get myComment(): boolean {
745 UserService.Instance.user &&
746 this.props.node.comment.creator_id == UserService.Instance.user.id
750 get isMod(): boolean {
752 this.props.moderators &&
754 this.props.moderators.map(m => m.user_id),
755 this.props.node.comment.creator_id
760 get isAdmin(): boolean {
764 this.props.admins.map(a => a.id),
765 this.props.node.comment.creator_id
770 get isPostCreator(): boolean {
771 return this.props.node.comment.creator_id == this.props.postCreatorId;
774 get canMod(): boolean {
775 if (this.props.admins && this.props.moderators) {
776 let adminsThenMods = this.props.admins
778 .concat(this.props.moderators.map(m => m.user_id));
781 UserService.Instance.user,
783 this.props.node.comment.creator_id
790 get canAdmin(): boolean {
794 UserService.Instance.user,
795 this.props.admins.map(a => a.id),
796 this.props.node.comment.creator_id
801 get amCommunityCreator(): boolean {
803 this.props.moderators &&
804 UserService.Instance.user &&
805 this.props.node.comment.creator_id != UserService.Instance.user.id &&
806 UserService.Instance.user.id == this.props.moderators[0].user_id
810 get amSiteCreator(): boolean {
813 UserService.Instance.user &&
814 this.props.node.comment.creator_id != UserService.Instance.user.id &&
815 UserService.Instance.user.id == this.props.admins[0].id
819 get commentUnlessRemoved(): string {
820 let node = this.props.node;
821 return node.comment.removed
822 ? `*${i18n.t('removed')}*`
823 : node.comment.deleted
824 ? `*${i18n.t('deleted')}*`
825 : node.comment.content;
828 handleReplyClick(i: CommentNode) {
829 i.state.showReply = true;
833 handleEditClick(i: CommentNode) {
834 i.state.showEdit = true;
838 handleDeleteClick(i: CommentNode) {
839 let deleteForm: CommentFormI = {
840 content: i.props.node.comment.content,
841 edit_id: i.props.node.comment.id,
842 creator_id: i.props.node.comment.creator_id,
843 post_id: i.props.node.comment.post_id,
844 parent_id: i.props.node.comment.parent_id,
845 deleted: !i.props.node.comment.deleted,
848 WebSocketService.Instance.editComment(deleteForm);
851 handleSaveCommentClick(i: CommentNode) {
853 i.props.node.comment.saved == undefined
855 : !i.props.node.comment.saved;
856 let form: SaveCommentForm = {
857 comment_id: i.props.node.comment.id,
861 WebSocketService.Instance.saveComment(form);
863 i.state.saveLoading = true;
864 i.setState(this.state);
867 handleReplyCancel() {
868 this.state.showReply = false;
869 this.state.showEdit = false;
870 this.setState(this.state);
873 handleCommentUpvote(i: CommentNodeI) {
874 let new_vote = this.state.my_vote == 1 ? 0 : 1;
876 if (this.state.my_vote == 1) {
878 this.state.upvotes--;
879 } else if (this.state.my_vote == -1) {
880 this.state.downvotes--;
881 this.state.upvotes++;
882 this.state.score += 2;
884 this.state.upvotes++;
888 this.state.my_vote = new_vote;
890 let form: CommentLikeForm = {
891 comment_id: i.comment.id,
892 post_id: i.comment.post_id,
893 score: this.state.my_vote,
896 WebSocketService.Instance.likeComment(form);
897 this.setState(this.state);
901 handleCommentDownvote(i: CommentNodeI) {
902 let new_vote = this.state.my_vote == -1 ? 0 : -1;
904 if (this.state.my_vote == 1) {
905 this.state.score -= 2;
906 this.state.upvotes--;
907 this.state.downvotes++;
908 } else if (this.state.my_vote == -1) {
909 this.state.downvotes--;
912 this.state.downvotes++;
916 this.state.my_vote = new_vote;
918 let form: CommentLikeForm = {
919 comment_id: i.comment.id,
920 post_id: i.comment.post_id,
921 score: this.state.my_vote,
924 WebSocketService.Instance.likeComment(form);
925 this.setState(this.state);
929 handleModRemoveShow(i: CommentNode) {
930 i.state.showRemoveDialog = true;
934 handleModRemoveReasonChange(i: CommentNode, event: any) {
935 i.state.removeReason = event.target.value;
939 handleModRemoveSubmit(i: CommentNode) {
940 event.preventDefault();
941 let form: CommentFormI = {
942 content: i.props.node.comment.content,
943 edit_id: i.props.node.comment.id,
944 creator_id: i.props.node.comment.creator_id,
945 post_id: i.props.node.comment.post_id,
946 parent_id: i.props.node.comment.parent_id,
947 removed: !i.props.node.comment.removed,
948 reason: i.state.removeReason,
951 WebSocketService.Instance.editComment(form);
953 i.state.showRemoveDialog = false;
957 handleMarkRead(i: CommentNode) {
958 // if it has a user_mention_id field, then its a mention
959 if (i.props.node.comment.user_mention_id) {
960 let form: EditUserMentionForm = {
961 user_mention_id: i.props.node.comment.user_mention_id,
962 read: !i.props.node.comment.read,
964 WebSocketService.Instance.editUserMention(form);
966 let form: CommentFormI = {
967 content: i.props.node.comment.content,
968 edit_id: i.props.node.comment.id,
969 creator_id: i.props.node.comment.creator_id,
970 post_id: i.props.node.comment.post_id,
971 parent_id: i.props.node.comment.parent_id,
972 read: !i.props.node.comment.read,
975 WebSocketService.Instance.editComment(form);
978 i.state.readLoading = true;
979 i.setState(this.state);
982 handleModBanFromCommunityShow(i: CommentNode) {
983 i.state.showBanDialog = !i.state.showBanDialog;
984 i.state.banType = BanType.Community;
988 handleModBanShow(i: CommentNode) {
989 i.state.showBanDialog = !i.state.showBanDialog;
990 i.state.banType = BanType.Site;
994 handleModBanReasonChange(i: CommentNode, event: any) {
995 i.state.banReason = event.target.value;
999 handleModBanExpiresChange(i: CommentNode, event: any) {
1000 i.state.banExpires = event.target.value;
1001 i.setState(i.state);
1004 handleModBanFromCommunitySubmit(i: CommentNode) {
1005 i.state.banType = BanType.Community;
1006 i.setState(i.state);
1007 i.handleModBanBothSubmit(i);
1010 handleModBanSubmit(i: CommentNode) {
1011 i.state.banType = BanType.Site;
1012 i.setState(i.state);
1013 i.handleModBanBothSubmit(i);
1016 handleModBanBothSubmit(i: CommentNode) {
1017 event.preventDefault();
1019 if (i.state.banType == BanType.Community) {
1020 let form: BanFromCommunityForm = {
1021 user_id: i.props.node.comment.creator_id,
1022 community_id: i.props.node.comment.community_id,
1023 ban: !i.props.node.comment.banned_from_community,
1024 reason: i.state.banReason,
1025 expires: getUnixTime(i.state.banExpires),
1027 WebSocketService.Instance.banFromCommunity(form);
1029 let form: BanUserForm = {
1030 user_id: i.props.node.comment.creator_id,
1031 ban: !i.props.node.comment.banned,
1032 reason: i.state.banReason,
1033 expires: getUnixTime(i.state.banExpires),
1035 WebSocketService.Instance.banUser(form);
1038 i.state.showBanDialog = false;
1039 i.setState(i.state);
1042 handleShowConfirmAppointAsMod(i: CommentNode) {
1043 i.state.showConfirmAppointAsMod = true;
1044 i.setState(i.state);
1047 handleCancelConfirmAppointAsMod(i: CommentNode) {
1048 i.state.showConfirmAppointAsMod = false;
1049 i.setState(i.state);
1052 handleAddModToCommunity(i: CommentNode) {
1053 let form: AddModToCommunityForm = {
1054 user_id: i.props.node.comment.creator_id,
1055 community_id: i.props.node.comment.community_id,
1058 WebSocketService.Instance.addModToCommunity(form);
1059 i.state.showConfirmAppointAsMod = false;
1060 i.setState(i.state);
1063 handleShowConfirmAppointAsAdmin(i: CommentNode) {
1064 i.state.showConfirmAppointAsAdmin = true;
1065 i.setState(i.state);
1068 handleCancelConfirmAppointAsAdmin(i: CommentNode) {
1069 i.state.showConfirmAppointAsAdmin = false;
1070 i.setState(i.state);
1073 handleAddAdmin(i: CommentNode) {
1074 let form: AddAdminForm = {
1075 user_id: i.props.node.comment.creator_id,
1078 WebSocketService.Instance.addAdmin(form);
1079 i.state.showConfirmAppointAsAdmin = false;
1080 i.setState(i.state);
1083 handleShowConfirmTransferCommunity(i: CommentNode) {
1084 i.state.showConfirmTransferCommunity = true;
1085 i.setState(i.state);
1088 handleCancelShowConfirmTransferCommunity(i: CommentNode) {
1089 i.state.showConfirmTransferCommunity = false;
1090 i.setState(i.state);
1093 handleTransferCommunity(i: CommentNode) {
1094 let form: TransferCommunityForm = {
1095 community_id: i.props.node.comment.community_id,
1096 user_id: i.props.node.comment.creator_id,
1098 WebSocketService.Instance.transferCommunity(form);
1099 i.state.showConfirmTransferCommunity = false;
1100 i.setState(i.state);
1103 handleShowConfirmTransferSite(i: CommentNode) {
1104 i.state.showConfirmTransferSite = true;
1105 i.setState(i.state);
1108 handleCancelShowConfirmTransferSite(i: CommentNode) {
1109 i.state.showConfirmTransferSite = false;
1110 i.setState(i.state);
1113 handleTransferSite(i: CommentNode) {
1114 let form: TransferSiteForm = {
1115 user_id: i.props.node.comment.creator_id,
1117 WebSocketService.Instance.transferSite(form);
1118 i.state.showConfirmTransferSite = false;
1119 i.setState(i.state);
1122 get isCommentNew(): boolean {
1123 let now = moment.utc().subtract(10, 'minutes');
1124 let then = moment.utc(this.props.node.comment.published);
1125 return now.isBefore(then);
1128 handleCommentCollapse(i: CommentNode) {
1129 i.state.collapsed = !i.state.collapsed;
1130 i.setState(i.state);
1133 handleViewSource(i: CommentNode) {
1134 i.state.viewSource = !i.state.viewSource;
1135 i.setState(i.state);
1138 handleShowAdvanced(i: CommentNode) {
1139 i.state.showAdvanced = !i.state.showAdvanced;
1140 i.setState(i.state);
1145 if (this.state.my_vote == 1) {
1147 } else if (this.state.my_vote == -1) {
1148 return 'text-danger';
1150 return 'text-muted';
1154 get pointsTippy(): string {
1155 let points = i18n.t('number_of_points', {
1156 count: this.state.score,
1159 let upvotes = i18n.t('number_of_upvotes', {
1160 count: this.state.upvotes,
1163 let downvotes = i18n.t('number_of_downvotes', {
1164 count: this.state.downvotes,
1167 return `${points} • ${upvotes} • ${downvotes}`;