Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordartcafe <github@dartcafe.de>2020-01-20 21:22:45 +0300
committerdartcafe <github@dartcafe.de>2020-01-20 21:22:45 +0300
commit5b38402dc5ad99ec32908290df459a6db2dd0c2d (patch)
treea48b6b97966726271d4252915d269b37ba4c966d /src/js/components/Comments/Comments.vue
parent07143e674eabeafbbfe7766401f8231cea18df98 (diff)
Fixed sorting comments
Diffstat (limited to 'src/js/components/Comments/Comments.vue')
-rw-r--r--src/js/components/Comments/Comments.vue24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/js/components/Comments/Comments.vue b/src/js/components/Comments/Comments.vue
index b373bb86..9c43ffa8 100644
--- a/src/js/components/Comments/Comments.vue
+++ b/src/js/components/Comments/Comments.vue
@@ -26,7 +26,7 @@
<CommentAdd v-if="acl.allowComment" />
<transition-group v-if="countComments" name="fade" class="comments"
tag="ul">
- <li v-for="(comment) in sortedComments" :key="comment.id">
+ <li v-for="(comment) in sortedList" :key="comment.id">
<div class="comment-item">
<user-div :user-id="comment.userId" />
<div class="date">
@@ -48,22 +48,38 @@
<script>
import CommentAdd from './CommentAdd'
import { mapState, mapGetters } from 'vuex'
+import sortBy from 'lodash/sortBy'
export default {
name: 'Comments',
components: {
CommentAdd
},
+ data() {
+ return {
+ sort: 'timestamp',
+ reverse: true
+ }
+ },
computed: {
...mapState({
comments: state => state.comments,
acl: state => state.acl
}),
+
...mapGetters([
- 'countComments',
- 'sortedComments'
- ])
+ 'countComments'
+ ]),
+
+ sortedList() {
+ if (this.reverse) {
+ return sortBy(this.comments.list, this.sort).reverse()
+ } else {
+ return sortBy(this.comments.list, this.sort)
+ }
+ }
+
}
}
</script>