use constants, truncate only comments with more than 300 characters

This commit is contained in:
Alina Beck 2019-10-16 13:56:57 +03:00
parent 452bf4127c
commit a306b9cf4b
2 changed files with 5 additions and 2 deletions

View File

@ -60,6 +60,7 @@
<script>
import { mapGetters } from 'vuex'
import { COMMENT_MAX_UNTRUNCATED_LENGTH, COMMENT_TRUNCATE_TO_LENGTH } from '~/constants/comment'
import HcUser from '~/components/User/User'
import ContentMenu from '~/components/ContentMenu'
import ContentViewer from '~/components/Editor/ContentViewer'
@ -98,11 +99,11 @@ export default {
isModerator: 'auth/isModerator',
}),
isLongComment() {
return this.$filters.removeHtml(this.comment.content).length > 180
return this.$filters.removeHtml(this.comment.content).length > COMMENT_MAX_UNTRUNCATED_LENGTH
},
commentContent() {
if (this.isLongComment && this.isCollapsed) {
return this.$filters.truncate(this.comment.content, 180)
return this.$filters.truncate(this.comment.content, COMMENT_TRUNCATE_TO_LENGTH)
}
return this.comment.content

View File

@ -1 +1,3 @@
export const COMMENT_MIN_LENGTH = 1
export const COMMENT_MAX_UNTRUNCATED_LENGTH = 300
export const COMMENT_TRUNCATE_TO_LENGTH = 180