1 import { Component, linkEvent } from 'inferno';
2 import { Link } from 'inferno-router';
12 CommunityModeratorView,
21 } from 'lemmy-js-client';
24 CommentNode as CommentNodeI,
26 } from '../interfaces';
27 import { WebSocketService, UserService } from '../services';
38 import moment from 'moment';
39 import { MomentTime } from './moment-time';
40 import { CommentForm } from './comment-form';
41 import { CommentNodes } from './comment-nodes';
42 import { UserListing } from './user-listing';
43 import { CommunityLink } from './community-link';
44 import { i18n } from '../i18next';
46 interface CommentNodeState {
49 showRemoveDialog: boolean;
51 showBanDialog: boolean;
56 showConfirmTransferSite: boolean;
57 showConfirmTransferCommunity: boolean;
58 showConfirmAppointAsMod: boolean;
59 showConfirmAppointAsAdmin: boolean;
62 showAdvanced: boolean;
72 interface CommentNodeProps {
79 showContext?: boolean;
80 moderators: CommunityModeratorView[];
81 admins: UserViewSafe[];
82 // TODO is this necessary, can't I get it from the node itself?
83 postCreatorId?: number;
84 showCommunity?: boolean;
85 sort?: CommentSortType;
87 enableDownvotes: boolean;
90 export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
91 private emptyState: CommentNodeState = {
94 showRemoveDialog: false,
100 banType: BanType.Community,
104 showConfirmTransferSite: false,
105 showConfirmTransferCommunity: false,
106 showConfirmAppointAsMod: false,
107 showConfirmAppointAsAdmin: false,
108 my_vote: this.props.node.comment_view.my_vote,
109 score: this.props.node.comment_view.counts.score,
110 upvotes: this.props.node.comment_view.counts.upvotes,
111 downvotes: this.props.node.comment_view.counts.downvotes,
112 borderColor: this.props.node.depth
113 ? colorList[this.props.node.depth % colorList.length]
119 constructor(props: any, context: any) {
120 super(props, context);
122 this.state = this.emptyState;
123 this.handleReplyCancel = this.handleReplyCancel.bind(this);
124 this.handleCommentUpvote = this.handleCommentUpvote.bind(this);
125 this.handleCommentDownvote = this.handleCommentDownvote.bind(this);
128 // TODO see if there's a better way to do this, and all willReceiveProps
129 componentWillReceiveProps(nextProps: CommentNodeProps) {
130 let cv = nextProps.node.comment_view;
131 this.state.my_vote = cv.my_vote;
132 this.state.upvotes = cv.counts.upvotes;
133 this.state.downvotes = cv.counts.downvotes;
134 this.state.score = cv.counts.score;
135 this.state.readLoading = false;
136 this.state.saveLoading = false;
137 this.setState(this.state);
141 let node = this.props.node;
142 let cv = this.props.node.comment_view;
145 className={`comment ${
146 cv.comment.parent_id && !this.props.noIndent ? 'ml-1' : ''
150 id={`comment-${cv.comment.id}`}
151 className={`details comment-node py-2 ${
152 !this.props.noBorder ? 'border-top border-light' : ''
153 } ${this.isCommentNew ? 'mark' : ''}`}
155 !this.props.noIndent &&
156 cv.comment.parent_id &&
157 `border-left: 2px ${this.state.borderColor} solid !important`
161 class={`${!this.props.noIndent && cv.comment.parent_id && 'ml-2'}`}
163 <div class="d-flex flex-wrap align-items-center text-muted small">
165 <UserListing user={cv.creator} />
169 <div className="badge badge-light d-none d-sm-inline mr-2">
174 <div className="badge badge-light d-none d-sm-inline mr-2">
178 {this.isPostCreator && (
179 <div className="badge badge-light d-none d-sm-inline mr-2">
183 {(cv.creator_banned_from_community || cv.creator.banned) && (
184 <div className="badge badge-danger mr-2">
188 {this.props.showCommunity && (
190 <span class="mx-1">{i18n.t('to')}</span>
191 <CommunityLink community={cv.community} />
192 <span class="mx-2">•</span>
193 <Link className="mr-2" to={`/post/${cv.post.id}`}>
199 class="btn btn-sm text-muted"
200 onClick={linkEvent(this, this.handleCommentCollapse)}
202 {this.state.collapsed ? '+' : '—'}
204 {/* This is an expanding spacer for mobile */}
205 <div className="mr-lg-4 flex-grow-1 flex-lg-grow-0 unselectable pointer mx-2"></div>
207 className={`unselectable pointer ${this.scoreColor}`}
208 onClick={linkEvent(node, this.handleCommentUpvote)}
209 data-tippy-content={this.pointsTippy}
211 <span class="mr-1 font-weight-bold">{this.state.score}</span>
213 <span className="mr-1">•</span>
215 <MomentTime data={cv.comment} />
218 {/* end of user row */}
219 {this.state.showEdit && (
223 onReplyCancel={this.handleReplyCancel}
224 disabled={this.props.locked}
228 {!this.state.showEdit && !this.state.collapsed && (
230 {this.state.viewSource ? (
231 <pre>{this.commentUnlessRemoved}</pre>
235 dangerouslySetInnerHTML={mdToHtml(
236 this.commentUnlessRemoved
240 <div class="d-flex justify-content-between justify-content-lg-start flex-wrap text-muted font-weight-bold">
241 {this.props.showContext && this.linkBtn}
242 {this.props.markable && (
244 class="btn btn-link btn-animate text-muted"
245 onClick={linkEvent(this, this.handleMarkRead)}
248 ? i18n.t('mark_as_unread')
249 : i18n.t('mark_as_read')
252 {this.state.readLoading ? (
256 class={`icon icon-inline ${
257 cv.comment.read && 'text-success'
260 <use xlinkHref="#icon-check"></use>
265 {UserService.Instance.user && !this.props.viewOnly && (
268 className={`btn btn-link btn-animate ${
269 this.state.my_vote == 1 ? 'text-info' : 'text-muted'
271 onClick={linkEvent(node, this.handleCommentUpvote)}
272 data-tippy-content={i18n.t('upvote')}
274 <svg class="icon icon-inline">
275 <use xlinkHref="#icon-arrow-up1"></use>
277 {this.state.upvotes !== this.state.score && (
278 <span class="ml-1">{this.state.upvotes}</span>
281 {this.props.enableDownvotes && (
283 className={`btn btn-link btn-animate ${
284 this.state.my_vote == -1
288 onClick={linkEvent(node, this.handleCommentDownvote)}
289 data-tippy-content={i18n.t('downvote')}
291 <svg class="icon icon-inline">
292 <use xlinkHref="#icon-arrow-down1"></use>
294 {this.state.upvotes !== this.state.score && (
295 <span class="ml-1">{this.state.downvotes}</span>
300 class="btn btn-link btn-animate text-muted"
301 onClick={linkEvent(this, this.handleReplyClick)}
302 data-tippy-content={i18n.t('reply')}
304 <svg class="icon icon-inline">
305 <use xlinkHref="#icon-reply1"></use>
308 {!this.state.showAdvanced ? (
310 className="btn btn-link btn-animate text-muted"
311 onClick={linkEvent(this, this.handleShowAdvanced)}
312 data-tippy-content={i18n.t('more')}
314 <svg class="icon icon-inline">
315 <use xlinkHref="#icon-more-vertical"></use>
320 {!this.myComment && (
321 <button class="btn btn-link btn-animate">
323 className="text-muted"
324 to={`/create_private_message/recipient/${cv.creator.id}`}
325 title={i18n.t('message').toLowerCase()}
328 <use xlinkHref="#icon-mail"></use>
333 {!this.props.showContext && this.linkBtn}
335 class="btn btn-link btn-animate text-muted"
338 this.handleSaveCommentClick
341 cv.saved ? i18n.t('unsave') : i18n.t('save')
344 {this.state.saveLoading ? (
348 class={`icon icon-inline ${
349 cv.saved && 'text-warning'
352 <use xlinkHref="#icon-star"></use>
357 className="btn btn-link btn-animate text-muted"
358 onClick={linkEvent(this, this.handleViewSource)}
359 data-tippy-content={i18n.t('view_source')}
362 class={`icon icon-inline ${
363 this.state.viewSource && 'text-success'
366 <use xlinkHref="#icon-file-text"></use>
372 class="btn btn-link btn-animate text-muted"
373 onClick={linkEvent(this, this.handleEditClick)}
374 data-tippy-content={i18n.t('edit')}
376 <svg class="icon icon-inline">
377 <use xlinkHref="#icon-edit"></use>
381 class="btn btn-link btn-animate text-muted"
384 this.handleDeleteClick
393 class={`icon icon-inline ${
394 cv.comment.deleted && 'text-danger'
397 <use xlinkHref="#icon-trash"></use>
402 {/* Admins and mods can remove comments */}
403 {(this.canMod || this.canAdmin) && (
405 {!cv.comment.removed ? (
407 class="btn btn-link btn-animate text-muted"
410 this.handleModRemoveShow
417 class="btn btn-link btn-animate text-muted"
420 this.handleModRemoveSubmit
428 {/* Mods can ban from community, and appoint as mods to community */}
432 (!cv.creator_banned_from_community ? (
434 class="btn btn-link btn-animate text-muted"
437 this.handleModBanFromCommunityShow
444 class="btn btn-link btn-animate text-muted"
447 this.handleModBanFromCommunitySubmit
453 {!cv.creator_banned_from_community &&
455 (!this.state.showConfirmAppointAsMod ? (
457 class="btn btn-link btn-animate text-muted"
460 this.handleShowConfirmAppointAsMod
464 ? i18n.t('remove_as_mod')
465 : i18n.t('appoint_as_mod')}
469 <button class="btn btn-link btn-animate text-muted">
470 {i18n.t('are_you_sure')}
473 class="btn btn-link btn-animate text-muted"
476 this.handleAddModToCommunity
482 class="btn btn-link btn-animate text-muted"
485 this.handleCancelConfirmAppointAsMod
494 {/* Community creators and admins can transfer community to another mod */}
495 {(this.amCommunityCreator || this.canAdmin) &&
498 (!this.state.showConfirmTransferCommunity ? (
500 class="btn btn-link btn-animate text-muted"
503 this.handleShowConfirmTransferCommunity
506 {i18n.t('transfer_community')}
510 <button class="btn btn-link btn-animate text-muted">
511 {i18n.t('are_you_sure')}
514 class="btn btn-link btn-animate text-muted"
517 this.handleTransferCommunity
523 class="btn btn-link btn-animate text-muted"
527 .handleCancelShowConfirmTransferCommunity
534 {/* Admins can ban from all, and appoint other admins */}
538 (!cv.creator.banned ? (
540 class="btn btn-link btn-animate text-muted"
543 this.handleModBanShow
546 {i18n.t('ban_from_site')}
550 class="btn btn-link btn-animate text-muted"
553 this.handleModBanSubmit
556 {i18n.t('unban_from_site')}
559 {!cv.creator.banned &&
561 (!this.state.showConfirmAppointAsAdmin ? (
563 class="btn btn-link btn-animate text-muted"
566 this.handleShowConfirmAppointAsAdmin
570 ? i18n.t('remove_as_admin')
571 : i18n.t('appoint_as_admin')}
575 <button class="btn btn-link btn-animate text-muted">
576 {i18n.t('are_you_sure')}
579 class="btn btn-link btn-animate text-muted"
588 class="btn btn-link btn-animate text-muted"
591 this.handleCancelConfirmAppointAsAdmin
600 {/* Site Creator can transfer to another admin */}
601 {this.amSiteCreator &&
604 (!this.state.showConfirmTransferSite ? (
606 class="btn btn-link btn-animate text-muted"
609 this.handleShowConfirmTransferSite
612 {i18n.t('transfer_site')}
616 <button class="btn btn-link btn-animate text-muted">
617 {i18n.t('are_you_sure')}
620 class="btn btn-link btn-animate text-muted"
623 this.handleTransferSite
629 class="btn btn-link btn-animate text-muted"
632 this.handleCancelShowConfirmTransferSite
644 {/* end of button group */}
649 {/* end of details */}
650 {this.state.showRemoveDialog && (
653 onSubmit={linkEvent(this, this.handleModRemoveSubmit)}
657 class="form-control mr-2"
658 placeholder={i18n.t('reason')}
659 value={this.state.removeReason}
660 onInput={linkEvent(this, this.handleModRemoveReasonChange)}
662 <button type="submit" class="btn btn-secondary">
663 {i18n.t('remove_comment')}
667 {this.state.showBanDialog && (
668 <form onSubmit={linkEvent(this, this.handleModBanBothSubmit)}>
669 <div class="form-group row">
670 <label class="col-form-label">{i18n.t('reason')}</label>
673 class="form-control mr-2"
674 placeholder={i18n.t('reason')}
675 value={this.state.banReason}
676 onInput={linkEvent(this, this.handleModBanReasonChange)}
678 <div class="form-group">
679 <div class="form-check">
681 class="form-check-input"
682 id="mod-ban-remove-data"
684 checked={this.state.removeData}
685 onChange={linkEvent(this, this.handleModRemoveDataChange)}
687 <label class="form-check-label" htmlFor="mod-ban-remove-data">
688 {i18n.t('remove_posts_comments')}
693 {/* TODO hold off on expires until later */}
694 {/* <div class="form-group row"> */}
695 {/* <label class="col-form-label">Expires</label> */}
696 {/* <input type="date" class="form-control mr-2" placeholder={i18n.t('expires')} value={this.state.banExpires} onInput={linkEvent(this, this.handleModBanExpiresChange)} /> */}
698 <div class="form-group row">
699 <button type="submit" class="btn btn-secondary">
700 {i18n.t('ban')} {cv.creator.name}
705 {this.state.showReply && (
708 onReplyCancel={this.handleReplyCancel}
709 disabled={this.props.locked}
713 {node.children && !this.state.collapsed && (
715 nodes={node.children}
716 locked={this.props.locked}
717 moderators={this.props.moderators}
718 admins={this.props.admins}
719 postCreatorId={this.props.postCreatorId}
720 sort={this.props.sort}
721 sortType={this.props.sortType}
722 enableDownvotes={this.props.enableDownvotes}
725 {/* A collapsed clearfix */}
726 {this.state.collapsed && <div class="row col-12"></div>}
732 let cv = this.props.node.comment_view;
735 className="btn btn-link btn-animate text-muted"
736 to={`/post/${cv.post.id}/comment/${cv.comment.id}`}
737 title={this.props.showContext ? i18n.t('show_context') : i18n.t('link')}
739 <svg class="icon icon-inline">
740 <use xlinkHref="#icon-link"></use>
748 <svg class="icon icon-spinner spin">
749 <use xlinkHref="#icon-spinner"></use>
754 get myComment(): boolean {
756 UserService.Instance.user &&
757 this.props.node.comment_view.creator.id == UserService.Instance.user.id
761 get isMod(): boolean {
763 this.props.moderators &&
765 this.props.moderators.map(m => m.moderator.id),
766 this.props.node.comment_view.creator.id
771 get isAdmin(): boolean {
775 this.props.admins.map(a => a.user.id),
776 this.props.node.comment_view.creator.id
781 get isPostCreator(): boolean {
782 return this.props.node.comment_view.creator.id == this.props.postCreatorId;
785 get canMod(): boolean {
786 if (this.props.admins && this.props.moderators) {
787 let adminsThenMods = this.props.admins
789 .concat(this.props.moderators.map(m => m.moderator.id));
792 UserService.Instance.user,
794 this.props.node.comment_view.creator.id
801 get canAdmin(): boolean {
805 UserService.Instance.user,
806 this.props.admins.map(a => a.user.id),
807 this.props.node.comment_view.creator.id
812 get amCommunityCreator(): boolean {
814 this.props.moderators &&
815 UserService.Instance.user &&
816 this.props.node.comment_view.creator.id != UserService.Instance.user.id &&
817 UserService.Instance.user.id == this.props.moderators[0].moderator.id
821 get amSiteCreator(): boolean {
824 UserService.Instance.user &&
825 this.props.node.comment_view.creator.id != UserService.Instance.user.id &&
826 UserService.Instance.user.id == this.props.admins[0].user.id
830 get commentUnlessRemoved(): string {
831 let comment = this.props.node.comment_view.comment;
832 return comment.removed
833 ? `*${i18n.t('removed')}*`
835 ? `*${i18n.t('deleted')}*`
839 handleReplyClick(i: CommentNode) {
840 i.state.showReply = true;
844 handleEditClick(i: CommentNode) {
845 i.state.showEdit = true;
849 handleDeleteClick(i: CommentNode) {
850 let comment = i.props.node.comment_view.comment;
851 let deleteForm: DeleteComment = {
853 deleted: !comment.deleted,
856 WebSocketService.Instance.send(wsClient.deleteComment(deleteForm));
859 handleSaveCommentClick(i: CommentNode) {
860 let cv = i.props.node.comment_view;
861 let save = cv.saved == undefined ? true : !cv.saved;
862 let form: SaveComment = {
863 comment_id: cv.comment.id,
868 WebSocketService.Instance.send(wsClient.saveComment(form));
870 i.state.saveLoading = true;
871 i.setState(this.state);
874 handleReplyCancel() {
875 this.state.showReply = false;
876 this.state.showEdit = false;
877 this.setState(this.state);
880 handleCommentUpvote(i: CommentNodeI) {
881 let new_vote = this.state.my_vote == 1 ? 0 : 1;
883 if (this.state.my_vote == 1) {
885 this.state.upvotes--;
886 } else if (this.state.my_vote == -1) {
887 this.state.downvotes--;
888 this.state.upvotes++;
889 this.state.score += 2;
891 this.state.upvotes++;
895 this.state.my_vote = new_vote;
897 let form: CreateCommentLike = {
898 comment_id: i.comment_view.comment.id,
899 score: this.state.my_vote,
903 WebSocketService.Instance.send(wsClient.likeComment(form));
904 this.setState(this.state);
908 handleCommentDownvote(i: CommentNodeI) {
909 let new_vote = this.state.my_vote == -1 ? 0 : -1;
911 if (this.state.my_vote == 1) {
912 this.state.score -= 2;
913 this.state.upvotes--;
914 this.state.downvotes++;
915 } else if (this.state.my_vote == -1) {
916 this.state.downvotes--;
919 this.state.downvotes++;
923 this.state.my_vote = new_vote;
925 let form: CreateCommentLike = {
926 comment_id: i.comment_view.comment.id,
927 score: this.state.my_vote,
931 WebSocketService.Instance.send(wsClient.likeComment(form));
932 this.setState(this.state);
936 handleModRemoveShow(i: CommentNode) {
937 i.state.showRemoveDialog = true;
941 handleModRemoveReasonChange(i: CommentNode, event: any) {
942 i.state.removeReason = event.target.value;
946 handleModRemoveDataChange(i: CommentNode, event: any) {
947 i.state.removeData = event.target.checked;
951 handleModRemoveSubmit(i: CommentNode) {
952 let comment = i.props.node.comment_view.comment;
953 let form: RemoveComment = {
955 removed: !comment.removed,
956 reason: i.state.removeReason,
959 WebSocketService.Instance.send(wsClient.removeComment(form));
961 i.state.showRemoveDialog = false;
966 item: CommentView | UserMentionView
967 ): item is UserMentionView {
968 return (item as UserMentionView).user_mention.id !== undefined;
971 handleMarkRead(i: CommentNode) {
972 if (i.isUserMentionType(i.props.node.comment_view)) {
973 let form: MarkUserMentionAsRead = {
974 user_mention_id: i.props.node.comment_view.user_mention.id,
975 read: !i.props.node.comment_view.user_mention.read,
978 WebSocketService.Instance.send(wsClient.markUserMentionAsRead(form));
980 let form: MarkCommentAsRead = {
981 comment_id: i.props.node.comment_view.comment.id,
982 read: !i.props.node.comment_view.comment.read,
985 WebSocketService.Instance.send(wsClient.markCommentAsRead(form));
988 i.state.readLoading = true;
989 i.setState(this.state);
992 handleModBanFromCommunityShow(i: CommentNode) {
993 i.state.showBanDialog = !i.state.showBanDialog;
994 i.state.banType = BanType.Community;
998 handleModBanShow(i: CommentNode) {
999 i.state.showBanDialog = !i.state.showBanDialog;
1000 i.state.banType = BanType.Site;
1001 i.setState(i.state);
1004 handleModBanReasonChange(i: CommentNode, event: any) {
1005 i.state.banReason = event.target.value;
1006 i.setState(i.state);
1009 handleModBanExpiresChange(i: CommentNode, event: any) {
1010 i.state.banExpires = event.target.value;
1011 i.setState(i.state);
1014 handleModBanFromCommunitySubmit(i: CommentNode) {
1015 i.state.banType = BanType.Community;
1016 i.setState(i.state);
1017 i.handleModBanBothSubmit(i);
1020 handleModBanSubmit(i: CommentNode) {
1021 i.state.banType = BanType.Site;
1022 i.setState(i.state);
1023 i.handleModBanBothSubmit(i);
1026 handleModBanBothSubmit(i: CommentNode) {
1027 let cv = i.props.node.comment_view;
1029 if (i.state.banType == BanType.Community) {
1030 // If its an unban, restore all their data
1031 let ban = !cv.creator_banned_from_community;
1033 i.state.removeData = false;
1035 let form: BanFromCommunity = {
1036 user_id: cv.creator.id,
1037 community_id: cv.community.id,
1039 remove_data: i.state.removeData,
1040 reason: i.state.banReason,
1041 expires: getUnixTime(i.state.banExpires),
1044 WebSocketService.Instance.send(wsClient.banFromCommunity(form));
1046 // If its an unban, restore all their data
1047 let ban = !cv.creator.banned;
1049 i.state.removeData = false;
1051 let form: BanUser = {
1052 user_id: cv.creator.id,
1054 remove_data: i.state.removeData,
1055 reason: i.state.banReason,
1056 expires: getUnixTime(i.state.banExpires),
1059 WebSocketService.Instance.send(wsClient.banUser(form));
1062 i.state.showBanDialog = false;
1063 i.setState(i.state);
1066 handleShowConfirmAppointAsMod(i: CommentNode) {
1067 i.state.showConfirmAppointAsMod = true;
1068 i.setState(i.state);
1071 handleCancelConfirmAppointAsMod(i: CommentNode) {
1072 i.state.showConfirmAppointAsMod = false;
1073 i.setState(i.state);
1076 handleAddModToCommunity(i: CommentNode) {
1077 let cv = i.props.node.comment_view;
1078 let form: AddModToCommunity = {
1079 user_id: cv.creator.id,
1080 community_id: cv.community.id,
1084 WebSocketService.Instance.send(wsClient.addModToCommunity(form));
1085 i.state.showConfirmAppointAsMod = false;
1086 i.setState(i.state);
1089 handleShowConfirmAppointAsAdmin(i: CommentNode) {
1090 i.state.showConfirmAppointAsAdmin = true;
1091 i.setState(i.state);
1094 handleCancelConfirmAppointAsAdmin(i: CommentNode) {
1095 i.state.showConfirmAppointAsAdmin = false;
1096 i.setState(i.state);
1099 handleAddAdmin(i: CommentNode) {
1100 let form: AddAdmin = {
1101 user_id: i.props.node.comment_view.creator.id,
1105 WebSocketService.Instance.send(wsClient.addAdmin(form));
1106 i.state.showConfirmAppointAsAdmin = false;
1107 i.setState(i.state);
1110 handleShowConfirmTransferCommunity(i: CommentNode) {
1111 i.state.showConfirmTransferCommunity = true;
1112 i.setState(i.state);
1115 handleCancelShowConfirmTransferCommunity(i: CommentNode) {
1116 i.state.showConfirmTransferCommunity = false;
1117 i.setState(i.state);
1120 handleTransferCommunity(i: CommentNode) {
1121 let cv = i.props.node.comment_view;
1122 let form: TransferCommunity = {
1123 community_id: cv.community.id,
1124 user_id: cv.creator.id,
1127 WebSocketService.Instance.send(wsClient.transferCommunity(form));
1128 i.state.showConfirmTransferCommunity = false;
1129 i.setState(i.state);
1132 handleShowConfirmTransferSite(i: CommentNode) {
1133 i.state.showConfirmTransferSite = true;
1134 i.setState(i.state);
1137 handleCancelShowConfirmTransferSite(i: CommentNode) {
1138 i.state.showConfirmTransferSite = false;
1139 i.setState(i.state);
1142 handleTransferSite(i: CommentNode) {
1143 let form: TransferSite = {
1144 user_id: i.props.node.comment_view.creator.id,
1147 WebSocketService.Instance.send(wsClient.transferSite(form));
1148 i.state.showConfirmTransferSite = false;
1149 i.setState(i.state);
1152 get isCommentNew(): boolean {
1153 let now = moment.utc().subtract(10, 'minutes');
1154 let then = moment.utc(this.props.node.comment_view.comment.published);
1155 return now.isBefore(then);
1158 handleCommentCollapse(i: CommentNode) {
1159 i.state.collapsed = !i.state.collapsed;
1160 i.setState(i.state);
1163 handleViewSource(i: CommentNode) {
1164 i.state.viewSource = !i.state.viewSource;
1165 i.setState(i.state);
1168 handleShowAdvanced(i: CommentNode) {
1169 i.state.showAdvanced = !i.state.showAdvanced;
1170 i.setState(i.state);
1175 if (this.state.my_vote == 1) {
1177 } else if (this.state.my_vote == -1) {
1178 return 'text-danger';
1180 return 'text-muted';
1184 get pointsTippy(): string {
1185 let points = i18n.t('number_of_points', {
1186 count: this.state.score,
1189 let upvotes = i18n.t('number_of_upvotes', {
1190 count: this.state.upvotes,
1193 let downvotes = i18n.t('number_of_downvotes', {
1194 count: this.state.downvotes,
1197 return `${points} • ${upvotes} • ${downvotes}`;